去掉API21(5.0) Button自帶點擊陰影

第一種 簡單

  • style=”?android:attr/borderlessButtonStyle”
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button"
style="?android:attr/borderlessButtonStyle" />

第二種 簡單

  • style=”@style/Widget.AppCompat.Button.Borderless”
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button"
style="@style/Widget.AppCompat.Button.Borderless" />

第三種 自定義style (可複用)

  • 自定義樣式,如背景顏色,文字顏色,圓角等
  • 圓角button 原生自帶陰影效果影響很大
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button"
style="@style/MyButtonStyle" />
<style name="MyButtonStyle" parent="@style/Widget.AppCompat.Button.Borderless">
   <!--自定義屬性-->
</style>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章