Java 无法创建正确的形状
我正在尝试创建一个像这样的形状 但现在它看起来是什么样子 这是我的密码Java 无法创建正确的形状,java,android,android-drawable,Java,Android,Android Drawable,我正在尝试创建一个像这样的形状 但现在它看起来是什么样子 这是我的密码 <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="@color/somecolor" /> <corners android:radius="10dip" android:bottomLeftRadius="10dp" and
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/somecolor" />
<corners
android:radius="10dip"
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp" />
<padding
android:top="10dp"
android:bottom="10dp" />
</shape>
有什么帮助吗?custom\u layout.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke android:width="2dp" android:color="#ff207d94" />
<padding android:left="2dp"
android:top="2dp"
android:right="2dp"
android:bottom="2dp" />
<corners android:radius="5dp" />
<solid android:color="@color/somecolor" />
</shape>
你的观点
<View
android:id="@+id/myView"
android:layout_width="60dp" // width and height will decide the shape
android:layout_height="30dp"
android:background="@drawable/custom_layout"/>
到底是什么问题(尺寸/高度…)。 你试过在你的形状上添加一些ohter标签吗? 我用的是:
<shape>
<gradient
android:startColor="#525251"
android:endColor="#838181"
android:angle="270" />
<stroke
android:width="1dp"
android:color="#525251" />
<corners
android:radius="6dp" />
<padding
android:left="5dp"
android:top="5dp"
android:right="5dp"
android:bottom="5dp" />
</shape>
(宽度/高度在布局XML中定义)将
android:top
更改为android:left
和android:bottom
更改为android:right
您还可以对这些属性使用负值,这样您就可以微调您想要实现的目标 将
android:top
更改为android:left
并将android:bottom
更改为android:right
是的,它可以工作。非常感谢。愚蠢的错误:p.你能把这个作为答案写下来,这样我就可以接受了。@abforce