get the button's width and draw it on an absoulutelayout

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

get the button's width and draw it on an absoulutelayout

Postby tptptp0827 » Wed Jul 15, 2009 4:23 am

how could i get the button's width and draw on an absoulutelayout?

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void onCreate(Bundle savedInstanceState) {
  2.  
  3.  
  4.  
  5.     al = (AbsoluteLayout) findViewById(R.id.home_container);
  6.  
  7.     RTestButton = new Button(this);
  8.  
  9.     RTestButton.setText("blah...");
  10.  
  11.    
  12.  
  13.     // 320
  14.  
  15.     int screen_width  = this.getWindow().getWindowManager().getDefaultDisplay().getWidth();
  16.  
  17.     int btn_width = RTestButton.getWidth();
  18.  
  19.  
  20.  
  21.     // right-top
  22.  
  23.     al.addView(RTestButton, new AbsoluteLayout.LayoutParams(
  24.  
  25.         AbsoluteLayout.LayoutParams.WRAP_CONTENT,
  26.  
  27.         AbsoluteLayout.LayoutParams.WRAP_CONTENT,
  28.  
  29.         screen_width-btn_width,0));
  30.  
  31.     // btn_width returns 0..
  32.  
  33. }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
tptptp0827
Freshman
Freshman
 
Posts: 4
Joined: Mon Jun 08, 2009 3:12 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 3 guests