How To Define Button Background At One Place And Used Around The Whole App?
I would like all the buttons of my android application use the same background image, that's all buttons have attribute: android:background='@drawable/my_btn_bg' Is there any way
Solution 1:
For Android styles, you reference the preset attributes of R.attr. Here, you want to to reference android:buttonStyle. You can try this :
<stylename="ApplicationStyle"parent="android:Theme"><itemname="android:buttonStyle">@style/yourButton</item></style>
Also look in this Themes and Styles
Solution 2:
Define styles.xml with the below:
<?xml version="1.0" encoding="utf-8"?><resources><stylename="buttonStyle"><itemname="android:layout_width">fill_parent</item><itemname="android:layout_height">wrap_content</item><itemname="android:background">@drawable/bg_button</item></style></resources>
And use the same style for any button within your application as:
<Buttonandroid:text="Test Button"android:id="@+id/btnTest"style="@style/buttonStyle"></Button>
Post a Comment for "How To Define Button Background At One Place And Used Around The Whole App?"