使用 xml 可绘制重力右圆
Gravity right circle drawable by using xml
我正在尝试实现如下所示的可绘制对象:
我用这个xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:gravity="end">
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
>
<size
android:width="@dimen/bullet_size"
android:height="@dimen/bullet_size"
/>
<solid android:color="@color/colorPrimary"/>
</shape>
</item>
</layer-list>
但是得到了这个:
有什么想法是错误的吗?
我使用的重力右圈dralable如下:
textView.setBackgroundResources(R.drawable.right_shspe);
相应地更改宽度和高度,它会固定形状
我认为你应该将保持椭圆形的项目垂直居中,一切都会好起来的。
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:gravity="end|center_vertical">
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
>
<size
android:width="@dimen/bullet_size"
android:height="@dimen/bullet_size"
/>
<solid android:color="@color/colorPrimary"/>
</shape>
</item>
</layer-list>
我正在尝试实现如下所示的可绘制对象:
我用这个xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:gravity="end">
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
>
<size
android:width="@dimen/bullet_size"
android:height="@dimen/bullet_size"
/>
<solid android:color="@color/colorPrimary"/>
</shape>
</item>
</layer-list>
但是得到了这个:
有什么想法是错误的吗?
我使用的重力右圈dralable如下:
textView.setBackgroundResources(R.drawable.right_shspe);
相应地更改宽度和高度,它会固定形状
我认为你应该将保持椭圆形的项目垂直居中,一切都会好起来的。
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:gravity="end|center_vertical">
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
>
<size
android:width="@dimen/bullet_size"
android:height="@dimen/bullet_size"
/>
<solid android:color="@color/colorPrimary"/>
</shape>
</item>
</layer-list>