android - 如何在 XML drawable 中创建一个具有两个弯曲边的矩形?

标签 android drawable shapedrawable

我希望矩形的左右两侧(而不是角)弯曲。或者说椭圆形的顶边和底边是直的。

我怎样才能实现这样的目标?

enter image description here

最佳答案

在 textview 上试试这个,对于单个字符,它会显示一个圆圈,对于多个数字,它会自动扩展为您在上面显示的形状,但如果您严格想要上面的形状,只需在左右提供更大的填充

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <padding
        android:top="3dp"
        android:left="8dp"
        android:right="8dp" 
        android:bottom="3dp"/>

    <solid android:color="#E6121A" />

    <corners
        android:bottomLeftRadius="12dp"
        android:bottomRightRadius="12dp"
        android:topLeftRadius="12dp"
        android:topRightRadius="12dp" />

</shape> 

关于android - 如何在 XML drawable 中创建一个具有两个弯曲边的矩形?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18071216/

相关文章:

android - 为什么Android layer-list drawable如此智能?

安卓|有意地给出图像

android - Google Maps API v2 Android 添加可绘制形状作为标记

android - 图层列表未正确显示项目 Android

android - 我的图层列表可绘制有什么问题?

Android 将数据从 ListView 传递到弹出窗口

android - 在 RecyclerView 中按组划分元素

android - android 设备(android 3.0 或更新版本)中 UI 线程中的网络

android - 谷歌地图帮助

android - EditText 中可绘制对象的选择器