Reputation: 1036
I am customizing button style
<style name="custom_button" parent="@android:style/Widget.Button">
<item name="android:paddingTop">5dp</item>
<item name="android:paddingBottom">5dp</item>
<item name="android:textAllCaps">false</item>
<item name="colorButtonNormal">#f37022</item>
<item name="android:textColor">#ffffff</item>
</style>
Using as
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Prepaid Package"
style="@style/custom_button"/>`
But the color on colorButtonNormal
has appears on On press
state.
What to do now?
Upvotes: 2
Views: 246
Reputation:
I have taken the example from here.
If you want to customise the background depending on the state of the button:
create an xml file eg button_custom.xml in res/drawable/
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/button_pressed"
android:state_pressed="true" />
<item android:drawable="@drawable/button_focused"
android:state_focused="true" />
<item android:drawable="@drawable/button_default" />
</selector>
then for the actual button, add: You can incorporate your default with your custom background.
<Button
...
android:background="@drawable/button_custom" />
Also in your styles, to fix the background color of your custom button style:
<item name="android:background">#f37022</item>
"colorButtonNormal"
is not an attribute of button, you need to use the built in attributes, as you have for the other items.
Upvotes: 2