我想在单击按钮时旋转按钮内的图像。我尝试使用ImageView,它可以工作,但出于可访问性目的,我需要使用Button而不是ImageView。
点击前:
这里向下箭头是按钮背景。
点击后:
单击按钮会显示额外的数据并旋转背景箭头。如何在单击时动画和旋转按钮背景?
布局代码供参考:
点击前:
![enter image description here](https://istack.dev59.com/GNFah.webp)
点击后:
![enter image description here](https://istack.dev59.com/zySa5.webp)
布局代码供参考:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" >
<LinearLayout
android:id="@+id/cases_actions_row"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal" >
<Button
android:id="@+id/case_action_item_1"
style="@style/card_action_button"
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
<Button
android:id="@+id/case_action_item_2"
style="@style/card_action_button"
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
</LinearLayout>
<Button
android:id="@+id/cases_expand_button"
style="@style/card_action_button"
android:layout_height="20dp"
android:layout_width="20dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:background="@drawable/ic_arrow" />
</RelativeLayout>
ImageButton
继承自ImageView
。但它看起来像一个Button
。所以,如果它在ImageView
上工作(你说过的),它也会在ImageButton
上工作。 - Phantômaxx