1

我创建了一个自定义按钮,它出现在预览中,但不在我的手机上。最低 API 是 17,我手机的 API 是 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" />
4

1 回答 1

0

我想我发现了问题所在。我有 2 个 xml 文件,一个用于 api 21+,另一个用于 api 21-。我删除了两者,并为所有版本重新创建了一个新版本。我的问题已经解决了。

于 2018-11-21T11:13:26.563 回答