日拱一卒(二十二)
16lz
2021-12-04
Android ShapeDrawable在低版本(2.1及以下)设置android:XXRightRadius="0dp"无效解决方案:
比如想设置一个上左右圆角,下左右角的效果,则可以用放两个shape放到layerlist解决:
<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape> <solid android:color="@color/secondary_text_disabled_material_light" /> <corners android:bottomLeftRadius="0.0dip" android:bottomRightRadius="0.0dip" android:topLeftRadius="10.0dip" android:topRightRadius="10.0dip" /> <padding android:left="5dp" android:right="10dp" /> </shape> </item> <item android:left="10dp"> <shape> <solid android:color="@android:color/transparent" /> <corners android:bottomLeftRadius="0.0dip" android:bottomRightRadius="0.0dip" android:topLeftRadius="0.0dip" android:topRightRadius="0.0dip" /> </shape> </item></layer-list>
注意: (1)android:bottomRightRadius的是控件下左边的半径,android:bottomLeftRadius则是下右边的半径.
(2)layerlist中设置的padding在控件本身也设置了padding情况下会失效。
如:下面的test是一个上面的layerlist,Button有自己设置了padding,此情况下以button的为准。
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/test" android:padding="20dp" android:text="@string/hello_world" />
更多相关文章
- Android设置任何控件透明度
- Android(安卓)控件及其属性2
- 相对布局
- Android布局属性
- Android(安卓)Webview适配屏幕宽度
- android小问题:RadioButton设置文字在图片背景的下方
- Android(安卓)BitmapShader 实战 实现圆形、圆角图片
- Android(安卓)应用程序中-设置-蓝牙,若隐藏蓝牙功能
- Android中做一个无标题窗口