OK I have a Button which uses as its background a selector. I set the width and height to wrap_content. The content is some text I set. I'm expecting the button to be sized around the text like a native button but the button is huge , basically looks as big as its source image. The button image is a nine patch image and the button xml is inside a relative layout. What am I missing here?
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/holo_btn" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/holo_btn" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/holo_btn" />
<item android:drawable="@drawable/holo_btn" />
</selector>
<Button android:id="@+id/btnTaskPriorityLow"
android:paddingLeft="@dimen/paddingSmallButton" android:paddingRight="@dimen/paddingSmallButton"
android:text="@string/strTaskPriorityLow"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/textViewCalColor"
android:layout_toRightOf="@+id/textViewPriority"
android:layout_marginTop="@dimen/marginTopAppt"
android:background="@drawable/button_holo_sel"/>
If I understand you have a huge 9-Patch as background.
AFAIK, 9-Patch can be extended but not reduced. So you probably have to edit your 9-Patch to make it as small as possible. Usually you can reduce the center-strechable area to one pixel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With