1

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" />
EliodeBeirut
  • 74
  • 1
  • 13
  • The button is not appearing or the style is not set correctly? – forpas Nov 19 '18 at 20:53
  • the button is appearing,but not with the right style – EliodeBeirut Nov 20 '18 at 14:19
  • What theme is the Button being inflated with? Probably this is just your Activity's theme, but it could be different if the Button tag has a parent with the `android:theme: attribute (or if your LayoutInflater has a theme set explicitly). – Ben P. Nov 20 '18 at 15:55
  • And, I suppose, what theme does that theme derive from? The important piece of information I'm looking from here is if you're using an AppCompat theme, a MaterialComponents theme, or something else. – Ben P. Nov 20 '18 at 15:58

1 Answers1

0

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.

EliodeBeirut
  • 74
  • 1
  • 13