【发布时间】:2017-12-27 23:43:48
【问题描述】:
我有这个按钮,当我从
state1 到 state2 反之亦然。
心脏是 2 个不同的可绘制对象(@drawable/ic_fav_dish_color 和 @drawable/ic_fav_dish_grey),文本是 2 个不同的字符串(@string/dish_faved 和 @string/dish_not_faved)
我使用该代码在 xml 中制作了按钮:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/fav_dish_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_fav_dish_color"
android:gravity="start|center_vertical"
android:text="@string/dish_faved"
android:textAlignment="center"
android:layout_margin="8dp"/>
</LinearLayout>
【问题讨论】:
标签: android xml button onclick