我想创建具有圆角右下角 和右上角 的自定义按钮。
但是,我得到的是左下 和右上 圆角,尽管我的实现似乎没问题.
我做错了什么?
我使用存储在可绘制文件夹中的以下形状定义:
button_shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#F66622"/>
<padding
android:left="5dip"
android:top="5dip"
android:right="5dip"
android:bottom="5dip"
/>
<corners
android:radius="20dip"
android:bottomLeftRadius="0dip"
android:topLeftRadius="0dip"
/>
</shape>
布局文件是这样的:
main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg"
>
<Button
android:id="@+id/btnFoo"
android:text="@string/btn_foo_title"
android:background="@drawable/button_shape"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:layout_centerInParent="true"
android:textSize="26sp"
/>
</RelativeLayout>
这是结果:
我还尝试在 button_shape 文件中分别定义每个角半径
...
<corners
android:bottomLeftRadius="0dip"
android:topLeftRadius="0dip"
android:bottomRightRadius="20dip"
android:topRightRadius="20dip"
/>
...
...结果相同。
这个功能是否有可能在 Android SDK 中以某种方式搞砸了?
最佳答案
愚蠢的问题,但您是否尝试将 bottomLeft 舍入并查看它是否舍入右下角?我知道这不是真正的解决方案,但变通方法也不错。如果它看起来像您想要的方式,那么您如何实现它并不重要。
关于android - 凌乱的圆角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7900971/