Android 1.6 killed my custom buttons

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

Android 1.6 killed my custom buttons

Postby PaulFake » Tue Oct 06, 2009 2:47 am

Hi,

I updated my phone to version 1.6 today, and all of the custom buttons in my app no longer show up. I have verified that this is not something I broke in my code by running it on a 1.5 AVD, and it works just fine. The code for my custom buttons is very simple. They are declared in my xml file as such:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <com.bigdates.birthdaycalendar.WhiteRoundedButton
  2.  
  3.                                                 android:id="@+id/sendtext"
  4.  
  5.                                                 android:layout_width="wrap_content"
  6.  
  7.                                                 android:layout_height="wrap_content"
  8.  
  9.                                 />
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


and the button image is pulled from the resources in my ImageButton-derived class as follows:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. @Override
  2.  
  3.     protected void drawableStateChanged() {
  4.  
  5.         super.drawableStateChanged();
  6.  
  7.  
  8.  
  9.         Drawable drawable;
  10.  
  11.         int[] states = getDrawableState();
  12.  
  13.  
  14.  
  15.         if (StateSet.stateSetMatches(new int[] { R.attr.state_pressed }, states) || StateSet.stateSetMatches(new int[] { R.attr.state_focused }, states)) {
  16.  
  17.             drawable = buttonHighlightedImage();
  18.  
  19.         } else {
  20.  
  21.             drawable = buttonImage();
  22.  
  23.         }
  24.  
  25.  
  26.  
  27.         setImageDrawable(drawable);
  28.  
  29.     }
  30.  
  31.  
  32.  
  33.     // /////////////////////////////////////////////////////////////////////////////////////////////////
  34.  
  35.     // private
  36.  
  37.  
  38.  
  39.     private Drawable buttonImage()
  40.  
  41.     {
  42.  
  43.         return CcUtil.getDrawable(getClass(), "res/drawable/btndetailwhite.png");
  44.  
  45.     }
  46.  
  47.  
  48.  
  49.     private Drawable buttonHighlightedImage()
  50.  
  51.     {
  52.  
  53.         return CcUtil.getDrawable(getClass(), "res/drawable/btndetailwhite_pressed.png");
  54.  
  55.     }
Parsed in 0.043 seconds, using GeSHi 1.0.8.4


What the heck could have changed in 1.6 that made my buttons go away? I ALSO verified that the resources are loading properly by debugging...that is, the drawable returned from drawableStateChanged() is valid.
PaulFake
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed Aug 26, 2009 1:05 am

Top

Postby PaulFake » Fri Oct 09, 2009 6:28 am

The buttons come back when I get rid of the ScrollView that contains them...but I want both the buttons and the ScrollView. No idea what's going on.
PaulFake
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed Aug 26, 2009 1:05 am

Postby PaulFake » Sat Oct 10, 2009 3:18 am

I ended up fixing it by setting android:layout_width and android:layout_height to constant values, instead of wrap_content. Wrap_content doesn't seem to work when the button is contained in a scroll view. The "why" is beyond me.
PaulFake
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed Aug 26, 2009 1:05 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 3 guests