我无法使用XML创建简单的圆角矩形。每次我尝试了“弯道”元素添加到自定义形状,我得到:在 android.graphics.Path.addRoundRect(Path.java:514) Android - 无法创建简单的矩形形状... UnsupportedOperationException?
java.lang.UnsupportedOperationException 在 机器人.graphics.drawable.GradientDrawable.draw(GradientDrawable.java:314) 在 android.view.View.draw(View.java:6520) ...
RES/dawable/rounded_rectangle.xml:
使用上述形状<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#ffffff"/>
<stroke android:width="3dp"
android:color="#ff000000"/>
<padding android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp"/>
<corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp" android:topRightRadius="7dp"/>
</shape>
简单layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<View android:id="@+id/View01"
android:background="@drawable/rounded_rectangle"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</View>
</RelativeLayout>
据透露,我试图编译Android 2.1的,我都安装到Eclipse的最新动态和Android SDK。这种形状是我在另一个网站上看到的东西的直接副本,但由于某种原因,它不想为我工作。
谢谢。
请参阅Shape元素及其属性: http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape – vanna