简体   繁体   中英

Custom Button style is appearing in preview but not on device API 27

I created a custom button, it is appearing in the preview, but not on my phone. The minimum API is 17 and my phone's API is 27.

//custom button
<style name="taskButton"  parent="Widget.AppCompat.Button">
    <item name="android:layout_alignParentStart">true</item>
    <item name="android:drawablePadding">-3dp</item>
    <item name="android:background">@color/Red</item>
    <item name="android:textAlignment">viewStart</item>
</style>

//xml 
 <Button
                android:id="@+id/homeButton"
                style="@style/taskButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center|start"
                android:drawableStart="@drawable/ic_home_black_24dp"
                android:text="Home"
                android:textAllCaps="false"
                android:visibility="visible" />

I think I found out the problem. I had 2 xml files, one for api 21+ and another one for api 21-. I deleted both, and recreated a new one for all the versions. And my issue is fixed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM