3 回答

TA貢獻(xiàn)1155條經(jīng)驗(yàn) 獲得超0個(gè)贊
另一個(gè)簡(jiǎn)單的解決方案是為“平面”按鈕提供自定義背景,同時(shí)保持其“材質(zhì)”效果。
將按鈕放在ViewGroup中,并在此處設(shè)置所需的背景
將當(dāng)前主題中的selectableItemBackground設(shè)置為按鈕的背景(API> = 11)
即:
<FrameLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/blue"> <Button style="?android:attr/buttonStyleSmall" android:background="?android:attr/selectableItemBackground" android:textColor="@android:color/white" android:textAllCaps="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Button1" /></FrameLayout>
可以用于Flat按鈕,它適用于API> = 11,你將在> = 21設(shè)備上獲得連鎖效果,在21之前保持常規(guī)按鈕,直到AppCompat更新以支持那里的波紋。
您也可以僅對(duì)> = 21個(gè)按鈕使用selectableItemBackgroundBorderless。
另一個(gè)簡(jiǎn)單的解決方案是為“平面”按鈕提供自定義背景,同時(shí)保持其“材質(zhì)”效果。
將按鈕放在ViewGroup中,并在此處設(shè)置所需的背景
將當(dāng)前主題中的selectableItemBackground設(shè)置為按鈕的背景(API> = 11)
即:
<FrameLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/blue"> <Button style="?android:attr/buttonStyleSmall" android:background="?android:attr/selectableItemBackground" android:textColor="@android:color/white" android:textAllCaps="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Button1" /></FrameLayout>
可以用于Flat按鈕,它適用于API> = 11,你將在> = 21設(shè)備上獲得連鎖效果,在21之前保持常規(guī)按鈕,直到AppCompat更新以支持那里的波紋。
您也可以僅對(duì)> = 21個(gè)按鈕使用selectableItemBackgroundBorderless。
- 3 回答
- 0 關(guān)注
- 393 瀏覽
添加回答
舉報(bào)