我定义了一个 drawable
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
  <solid android:color="#ffffffff" />
  <size android:width="60dp"
        android:height="40dp" />
</shape>
但是如何在layout定义中使用它呢?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              >
    <ImageView
        android:src="@drawable/ic_title"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        />
</LinearLayout>
我仍然只看到黑色背景.
编辑:
结果我:在drawable xmlns宣言中错过了一个.现在这个例子适用于姜饼设备:)
小智 21
在drawable中我使用这个xml代码来定义边框和背景:
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
  <stroke android:width="4dp" android:color="#D8FDFB" /> 
  <padding android:left="7dp" android:top="7dp" 
    android:right="7dp" android:bottom="7dp" /> 
  <corners android:radius="4dp" /> 
  <solid android:color="#f0600000"/> 
</shape> 
son*_*nyd 15
我有类似的问题,发现如果你删除大小定义,它的工作原因是出于某种原因.
去掉:
<size
    android:width="60dp"
    android:height="40dp" />
从形状.
让我知道这个是否奏效!
| 归档时间: | 
 | 
| 查看次数: | 102043 次 | 
| 最近记录: |