在Android中创建两侧圆角的矩形形状可绘制对象

4
我创建了一个形状可绘制资源xml文件,用于创建具有两个侧面圆角的背景。这是我的Shape drawable代码。但它没有给我正确的结果。它给了我四个侧面圆形图像。所以我想知道如何创建两个侧面弯曲的形状图像。
谢谢。
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#0579CD" />
<corners
    android:bottomLeftRadius="0dp"
    android:bottomRightRadius="0dp"
    android:topLeftRadius="15dp"
    android:topRightRadius="15dp" />
<padding
    android:bottom="8dp"
    android:left="8dp"
    android:right="8dp"
    android:top="8dp" />

2个回答

5
只需将矿工值传递到非曲线角字段即可。在您的情况下:
<corners
android:bottomLeftRadius="0.1dp"
android:bottomRightRadius="0.1dp"
android:topLeftRadius="15dp"
android:topRightRadius="15dp" />

还有一件事。预览不会在图形布局中显示。你应该尝试在设备上查看。
我希望这能帮到你。


2
<corners
    android:bottomLeftRadius="0dp"
    android:bottomRightRadius="0dp"
    android:topLeftRadius="15dp"
    android:topRightRadius="15dp" 
/>

你正在给出所有边的半径,因此它会给出正确的结果。你只需要给出两个选项,例如:
<corners
    android:topLeftRadius="15dp"
    android:topRightRadius="15dp" 

/>

或者任何其他可能的条件。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接