android 按钮点击样式

2020-05-30  本文已影响0人  刘坤林

一、水波纹点击效果,包含2个文件

文件1:style_btn_click.xml

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
 android:color="@color/lightYellow" tools:ignore="NewApi">
 <item android:drawable="@drawable/style_btn_click_normal" />
</ripple>

文件2:style_btn_click_normal.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
 <solid android:color="@color/mainColor" />
 <corners android:radius="3dp" />
</shape>

使用方法:

<Button 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/style_btn_click"  />

二、普通点击变色样式

style_normal_btn_click.xml

使用方法:

```

<Button      

    android:layout_width="wrap_content"    

    android:layout_height="wrap_content"    

    android:background="@drawable/style_normal_btn_click "  />

```

或者可以使用工具类样式工具类

上一篇 下一篇

猜你喜欢

热点阅读