Hi ,
I am having the following code for drawing buttons in my project.
I am having a button which has three images for 1 button .Namely one image
for the rectangle and 2 images for the left and right side curves
respectively.
When the button has focus , there is another three images for focus and
similarly 3 images when button is pressed.
Following is the code.

public void setButtonStyle(Button btn) {

//The middle rectangle
        StateListDrawable drawables = new StateListDrawable();
        drawables.addState(new int[] { stateFocused, -statePressed },
                dButtonMidOverImage);
        drawables.addState(new int[] { stateFocused, statePressed },
                dButtonMidDownImage);
        drawables.addState(new int[] { -stateFocused, statePressed },
                dButtonMidDownImage);
        drawables.addState(new int[] { -stateChecked }, dButtonMidUpImage);

        btn.setBackgroundDrawable(drawables);

//The left curve
        StateListDrawable drawablesLeft = new StateListDrawable();
        drawablesLeft.addState(new int[] { stateFocused, -statePressed },
                dButtonLeftOverImage);
        drawablesLeft.addState(new int[] { stateFocused, statePressed },
                dButtonLeftDownImage);
        drawablesLeft.addState(new int[] { -stateFocused, statePressed },
                dButtonLeftDownImage);
        drawablesLeft.addState(new int[] { -stateChecked },
dButtonLeftUpImage);

        StateListDrawable drawablesRight = new StateListDrawable();
        drawablesRight.addState(new int[] { stateFocused, -statePressed },
                dButtonRightOverImage);

//The right curve
        drawablesRight.addState(new int[] { stateFocused, statePressed },
                dButtonRightDownImage);
        drawablesRight.addState(new int[] { -stateFocused, statePressed },
                dButtonRightDownImage);
        drawablesRight.addState(new int[] { -stateChecked },
                dButtonRightUpImage);

//Compound drawables set for left and right side.
        btn.setCompoundDrawablesWithIntrinsicBounds(drawablesLeft, null,
                drawablesRight, null);


    }
This thing which i have done runtime can be done in the XML too , but i want
to change themes runtime so my images for button will also change runtime.
If i do the code in the XML it works fine on both Android 1.5 as well as
Android 1.6 .But doing it in code distorts the images for 1.6 emulator.
I have attached the screen shot of the buttons on both 1.5 and 1.6
emulators.As you can see, the left and right curve images come almost to the
center and the centre image is expanded in 1.6 emulator. The same problem is
seen on HTC Desire (Android2.1)
Is there something wrong that i am doing . Is there any workaround for this
problem.
Thanks ,
Alok.,

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

<<attachment: Android1.5 Emulator_Button.JPG>>

<<attachment: Android1.6 Emulator_Button.JPG>>

<<attachment: Button Seperation.JPG>>

Reply via email to