背景图片中实现图片的平铺效果
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/bg"
android:tileMode="repeat" />
在定义的shape中添加背景图
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" android:padding="10dp">
<corners
android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp"/>
</shape>
</item>
<item android:drawable="@drawable/image_name_here" />
</layer-list>
选中非选中背景切换
在drawable文件夹中创建xml文件,内容如下:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/privacy_top_unselected" android:state_checked="false" />
<item android:drawable="@drawable/privacy_top_selected" android:state_checked="true" />
<item android:drawable="@drawable/privacy_top_selected" />
</selector>
选中非选中文本颜色切换
在res文件夹中创建color文件夹,在其中创建xml文件,内容如下:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="@color/white"></item>
<item android:state_checked="false" android:color="@color/black"></item>
</selector>
String.xml中引用公共item
在resources之上添加
<!DOCTYPE resources [
<!ENTITY ctrl_policy "\n">
<!ENTITY span_policy "">
]>
<resources>
然后在别的string处按如下方式引用
<string name="dialog_policy_content1">&span_policy;Hello World!</string>
ClickableSpan 移除文字下划线
关键点,重写updateDrawState方法。
//设置部分文字点击事件
ClickableSpan clickableSpan2 = new ClickableSpan() {
@Override
public void onClick(View widget) {
}
// 移除下划线 Described by lxj on 2020/12/22 15:51
@Override
public void updateDrawState(@NonNull TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
}
};