我有一个像这样的形状xml:
drawable/contact_list_fastscroll_bubble.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:topLeftRadius="44dp"
android:topRightRadius="44dp"
android:bottomLeftRadius="44dp"/>
<padding
android:paddingLeft="22dp"
android:paddingRight="22dp" />
<solid android:color="@color/app_color_green"/>
</shape>
在api 21上,它看起来像这样,是我想要的api 19。
谢谢!
编辑:
我在2个仿真器上截取屏幕截图,两者都基于Nexus 6p和2560x1440,只有api级别不同。
编辑2:
我想解释一下如何测量形状可绘制。
我使用这个drawable如下:
<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:fastScrollPreviewBackgroundRight">@drawable/contact_list_fastscroll_bubble</item>
</style>
其中contact_list_fastscroll_bubble
是上面发布的xml。
属性android:fastScrollPreviewBackgroundRight
设置fast scroller drawable
的{{1}}。所以ListView
负责衡量可绘制性。开发人员不需要设置drawable的大小。
答案 0 :(得分:0)
看起来圆角在Lollipop之前计入填充。创建drawable的两个变体。
没有额外的填充。
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:topLeftRadius="44dp"
android:topRightRadius="44dp"
android:bottomLeftRadius="44dp"/>
<solid android:color="@color/app_color_green"/>
</shape>
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:topLeftRadius="44dp"
android:topRightRadius="44dp"
android:bottomLeftRadius="44dp"/>
<padding
android:paddingLeft="22dp"
android:paddingRight="22dp" />
<solid android:color="@color/app_color_green"/>
</shape>
答案 1 :(得分:-1)
我不确定,但这可能是一个原因。你的形状是矩形的,你只是在圆形的角落,所以这是根据你的dp反射弧。在api 21(高分辨率设备)中,dp更像是它的外观圆形,但在api 19中,你可能会使用较少分辨率的设备,因此它会变成矩形。