3

我正在尝试通过将其包含在以下内容中来绘制一个矩形/layout/myactivity.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
  <corners
      android:radius="2dp"
      android:topRightRadius="0dp"
      android:bottomRightRadius="0dp"
      android:bottomLeftRadius="0dp" />
  <stroke
      android:width="1dp"
      android:color="@android:color/white" />
</shape>

当我尝试运行该项目时,我得到:

05-12 23:37:14.090: E/AndroidRuntime(541): Caused by: java.lang.ClassNotFoundException: android.view.shape
05-12 23:37:14.090: E/AndroidRuntime(541):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
05-12 23:37:14.090: E/AndroidRuntime(541):  at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-12 23:37:14.090: E/AndroidRuntime(541):  at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-12 23:37:14.090: E/AndroidRuntime(541):  at android.view.LayoutInflater.createView(LayoutInflater.java:552)
05-12 23:37:14.090: E/AndroidRuntime(541):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:636)
05-12 23:37:14.090: E/AndroidRuntime(541):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
05-12 23:37:14.090: E/AndroidRuntime(541):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
05-12 23:37:14.090: E/AndroidRuntime(541):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
05-12 23:37:14.090: E/AndroidRuntime(541):  ... 22 more

我错过了什么吗?

4

1 回答 1

11

您的 XML 代码很好,位置是问题所在。不要将此文件保存在您的res/layout文件夹中,而是将其保存在res/drawable特定的可绘制文件夹中,例如res/drawable-xhdpi.

于 2012-05-12T21:55:37.720 回答