我想旋轉按鈕內的圖像,單擊按鈕。我只用ImageView嘗試,它的工作原理,但爲了便於使用,我需要使用Button而不是ImageView。Android - 旋轉按鈕內的圖像
這裏的向下箭頭按鈕是背景。
點擊按鈕顯示額外的數據和背景箭頭旋轉。點擊時如何動畫和旋轉按鈕背景?參考
佈局代碼:
<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>
'我想只有ImageView的,它WOR KS,但爲了便於使用,我需要使用Button而不是ImageView.'或使用ImageButton –
謝謝Frank。我將閱讀文檔。我可以在改變圖像的同時添加動畫嗎? – kumar
'ImageButton'繼承自'ImageView'。但看起來像一個'Button'。所以,如果它在'ImageView'上工作(你這麼說),它也可以在'ImageButton'上工作。 –