我在搜索具有良好图形的按钮时发现了这段代码,
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<corners
android:radius="100dp"
/>
<gradient
android:angle="45"
android:centerX="35%"
android:centerColor="#7995A8"
android:startColor="#E8E8E8"
android:endColor="#000000"
android:type="linear"
/>
<padding
android:left="0dp"
android:top="0dp"
android:right="0dp"
android:bottom="0dp"
/>
<size
android:width="270dp"
android:height="60dp"
/>
<stroke
android:width="3dp"
android:color="#878787"
/>
</shape>但是,当我将其复制并粘贴到Android中的XML文件中时,它会显示并出错如下:
“元素形状没有必需的属性android:layout_height”
另一个错误是:
“元素形状没有必需的属性android:layout_width”
我试着设置android:layout_width=""和android:layout_heigth"",android:layout_width"wrap_content",android:layout_heigth="wrap_content",错误消失了,但是我不能设置任何按钮,因为它是背景.所以我不能以这种方式使用这个XML。
我该给他们做什么?
https://stackoverflow.com/questions/28376191
复制相似问题