2013-07-25 50 views
3

我创建了一个形状可绘制资源xml文件,用于创建一个具有两个侧弯曲角的背景。
在这里,我张贴我的代码形状drawable。但它没有给我正确的结果。它给我4侧弯曲的图像。 所以我只是想知道如何创建2侧弯曲形状的图像。创建矩形形状可绘制的两个侧弯角在android

感谢

<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" /> 

回答

4

只需将矿工值传递给非曲线拐角字段即可。 你的情况:

<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" 

/> 

或任何其他可能的情况。