Android 按代码更改按下的图像资源
是否可以对图像进行一些图像影响以模拟按下的状态?(减小APK的尺寸)Android 按代码更改按下的图像资源,android,android-layout,Android,Android Layout,是否可以对图像进行一些图像影响以模拟按下的状态?(减小APK的尺寸) 然后每个按钮也可以用XML定义: 按钮_正常: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColo
然后每个按钮也可以用XML定义:
按钮_正常:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#DD63594A"
android:endColor="#809C7D5A"
android:angle="90"/>
<stroke android:width="2dp" android:color="#FF524539" />
<!-- android:dashWidth="2dp" android:dashGap="1dp" /> -->
<padding android:left="4dp"
android:top="4dp"
android:right="4dp"
android:bottom="4dp"/>
<corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp" android:topRightRadius="7dp"/>
</shape>
按下按钮:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#80A57D08"
android:endColor="#DDE75D31"
android:angle="90"/>
<stroke android:width="2dp" android:color="#FF524539" />
<!-- android:dashWidth="2dp" android:dashGap="1dp" /> -->
<padding android:left="4dp"
android:top="4dp"
android:right="4dp"
android:bottom="4dp"/>
<corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp" android:topRightRadius="7dp"/>
</shape>
按钮聚焦:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#80E75D31"
android:endColor="#DDE75D31"
android:angle="90"/>
<stroke android:width="2dp" android:color="#FF524539" />
<!-- android:dashWidth="2dp" android:dashGap="1dp" /> -->
<padding android:left="4dp"
android:top="4dp"
android:right="4dp"
android:bottom="4dp"/>
<corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp" android:topRightRadius="7dp"/>
</shape>
就动画而言,它实际上取决于您想要做什么以及达到什么目的:
您可以自己制作(一帧接一帧),例如:&
或使用动画视图:
希望有帮助。这样可以节省空间;-)
仅供参考:如果您正在寻找压缩,请查看以下内容
然后每个按钮也可以用XML定义:
按钮_正常:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#DD63594A"
android:endColor="#809C7D5A"
android:angle="90"/>
<stroke android:width="2dp" android:color="#FF524539" />
<!-- android:dashWidth="2dp" android:dashGap="1dp" /> -->
<padding android:left="4dp"
android:top="4dp"
android:right="4dp"
android:bottom="4dp"/>
<corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp" android:topRightRadius="7dp"/>
</shape>
按下按钮:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#80A57D08"
android:endColor="#DDE75D31"
android:angle="90"/>
<stroke android:width="2dp" android:color="#FF524539" />
<!-- android:dashWidth="2dp" android:dashGap="1dp" /> -->
<padding android:left="4dp"
android:top="4dp"
android:right="4dp"
android:bottom="4dp"/>
<corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp" android:topRightRadius="7dp"/>
</shape>
按钮聚焦:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#80E75D31"
android:endColor="#DDE75D31"
android:angle="90"/>
<stroke android:width="2dp" android:color="#FF524539" />
<!-- android:dashWidth="2dp" android:dashGap="1dp" /> -->
<padding android:left="4dp"
android:top="4dp"
android:right="4dp"
android:bottom="4dp"/>
<corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp" android:topRightRadius="7dp"/>
</shape>
就动画而言,它实际上取决于您想要做什么以及达到什么目的:
您可以自己制作(一帧接一帧),例如:&
或使用动画视图:
希望有帮助。这样可以节省空间;-)
仅供参考:如果您正在寻找压缩,请查看以下内容