android - 凌乱的圆角

标签 android android-layout

我想创建具有圆角右下角右上角 的自定义按钮。

但是,我得到的是左下右上 圆角,尽管我的实现似乎没问题.

我做错了什么?

我使用存储在可绘制文件夹中的以下形状定义:

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>

布局文件是这样的:

ma​​in.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>

这是结果:

messed corners

我还尝试在 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/

相关文章:

android - 任务 ':react-native-get-sms-android:verifyReleaseResources' 的 React Native 构建错误执行失败

android - 当标题 View 设置为 View.GONE 时,ListView 不收缩

java - RecyclerView 中的 CardView 垂直滚动

android - android studio中layout和layout v17的区别

android - 默认添加线性布局边距。如何避免这种情况?安卓

android - 如何使用 Button 更改 TextView

android - 每次手机休眠时定时器都会停止

java - 使用 EventBus 将数据从 Activity 发送到 Fragment

java - 在 Android 中的 Fragment 中使用 WebView 时,页面显示未格式化的文本

android - listview android中的按钮位置