changing button width

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

changing button width

Postby Afternundelite » Mon Feb 21, 2011 11:27 pm

Hi,

When I try to change a button's width with the Button.setWidth(int) method, it completely ignores my command, and instead sets it to be width 100.

Anyone else came across this problem?
It works great on my device, but the emulator is really acting up!

Thanks,

Afternundelite

this is my button in layout.xml:
Code: Select all
<Button
   android:id="@+id/stat"
   android:background="@drawable/statbar"
   android:layout_gravity="top|left"
   android:layout_marginBottom="0dip"
   android:layout_marginRight="0dip"
   android:layout_marginTop="265dip"
   android:layout_marginLeft="120dip"
   android:layout_height="wrap_content"
   android:layout_width="wrap_content"
   android:maxHeight="20dip"
   android:maxWidth="300dip"
   android:width="20dip"
   android:height="20dip"
   android:textSize="10dip"
   android:textStyle="bold"
   android:textColor="#FFFFFF"
   >

</Button>



and this is the code where I try to change the width:
Code: Select all
button.setWidth(10);
Afternundelite
Freshman
Freshman
 
Posts: 5
Joined: Thu Nov 18, 2010 1:26 am

Top

Re: changing button width

Postby blundell » Sat Feb 26, 2011 12:54 pm

Why have you got layout_width and android:width and then setting width programmatically?

Are you setting it programmatically, after you have inflated the view from XML?
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 7 guests