如何为 API 级别 < 23 的项目设置重力
How to set gravity for item for API level < 23
如何在 layer-list
内为 API 级别 < 23 设置 item
的重力?
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<gradient
android:startColor="#A7A7A7"
android:endColor="#C2C2C2"
android:angle="315" />
<corners
android:topLeftRadius="14dp"
android:topRightRadius="14dp" />
</shape>
</item>
<item android:gravity="bottom"><!--This is not working-->
<shape android:shape="rectangle">
<solid android:color="#FF5F5D" />
<size android:height="16dp" />
</shape>
</item>
</layer-list>
这样试试
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#FF5F5D" />
<corners android:topLeftRadius="14dp"
android:topRightRadius="14dp" />
</shape>
</item>
<item
android:bottom="16dp">
<shape android:shape="rectangle"
android:visible="true"
android:dither="true"
android:useLevel="false">
<gradient
android:startColor="#A7A7A7"
android:endColor="#C2C2C2"
android:angle="315" />
<corners android:topLeftRadius="14dp"
android:topRightRadius="14dp" />
</shape>
</item>
</layer-list>
如何在 layer-list
内为 API 级别 < 23 设置 item
的重力?
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<gradient
android:startColor="#A7A7A7"
android:endColor="#C2C2C2"
android:angle="315" />
<corners
android:topLeftRadius="14dp"
android:topRightRadius="14dp" />
</shape>
</item>
<item android:gravity="bottom"><!--This is not working-->
<shape android:shape="rectangle">
<solid android:color="#FF5F5D" />
<size android:height="16dp" />
</shape>
</item>
</layer-list>
这样试试
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#FF5F5D" />
<corners android:topLeftRadius="14dp"
android:topRightRadius="14dp" />
</shape>
</item>
<item
android:bottom="16dp">
<shape android:shape="rectangle"
android:visible="true"
android:dither="true"
android:useLevel="false">
<gradient
android:startColor="#A7A7A7"
android:endColor="#C2C2C2"
android:angle="315" />
<corners android:topLeftRadius="14dp"
android:topRightRadius="14dp" />
</shape>
</item>
</layer-list>