Reputation: 1058
So I applied a custom style to my buttons, it works ok with API level 22, but when I test it with API level 16 all my custom styles are gone. What's happening here?. I am an android beginner so probably it's a common behavior but I couldn't find any answer.
Styles are split into 4 xml's representing button states: Pressed, focused, disabled and enabled. I grouped them in 1 xml called button.xml and applied it in styles.xml
button_pressed.xml (focused, disabled and enabled are similar)
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="90"
android:endColor="#004B8D"
android:startColor="#0865B7" />
<size
android:height="65dp"
android:width="65dp"/>
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp" />
<stroke
android:width="1dp"
android:color="#FFFFFF" />
<corners android:radius="3dp" />
</shape>
button.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_enabled="false"
android:drawable="@drawable/button_disabled" />
<item
android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/button_pressed" />
<item
android:state_focused="true"
android:state_enabled="true"
android:drawable="@drawable/button_focused" />
<item
android:state_enabled="true"
android:drawable="@drawable/button_enabled" />
</selector>
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name ="android:buttonStyle">@style/button</item>
</style>
<style name="button" parent="@android:style/Widget.Button">
<item name="android:gravity">center_vertical|center_horizontal</item>
<item name="android:textColor">#FFFFFFFF</item>
<item name="android:shadowColor">#000000</item>
<item name="android:shadowDx">0</item>
<item name="android:shadowDy">-1</item>
<item name="android:shadowRadius">0.4</item>
<item name="android:textSize">20sp</item>
<item name="android:textStyle">bold</item>
<item name="android:background">@drawable/button</item>
<item name="android:focusable">false</item>
<item name="android:clickable">true</item>
<item name="android:fontFamily">sans-serif-condensed</item>
</style>
Upvotes: 1
Views: 706
Reputation: 22945
If you are using appcompat-v7 22.2.1 than it will use material design due to this reason it will be not supported in API 16.
for further information see design support library description
may this answer help to solve your issue.
Upvotes: 2
Reputation: 1064
Not all styles are supported out of the box on older android versions. Thats why you could probably notice folders such as values -14 values-16 values-21
Without you providing actual styles code, we cannot help you further.
Upvotes: 1