今天写程序,从一个Activity跳到另一个Activity,页面加载时出现了以下错误:
06-03 03:23:27.289: E/AndroidRuntime(9939): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.zuo.txt/com.zuo.txt.EditPage}: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12
绞尽脑汁,也没想出哪里有问题,页面代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:staggered="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="@color/edit_select"
android:orientation="vertical" >
<TextView
android:id="@+id/spinner_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="25sp"
android:textColor="#ff0000" />
<LinearLayout
android:id="@+id/relativeLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/edit_select">
<Spinner
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="5"
android:layout_marginLeft="10dp"
android:background="@drawable/shape"
android:textSize="12sp"
/>
<ImageButton
android:id="@+id/ib_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="@+id/spinner"
android:layout_marginEnd="@+id/spinner"
android:background="@drawable/imbutton"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:contentDescription="isearch"
android:src="@drawable/ic_search" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/edit_select"
android:orientation="horizontal" >
<com.origamilabs.library.views.StaggeredGridView
android:id="@+id/staggeredGridView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
staggered:drawSelectorOnTop="true"
staggered:numColumns="2" />
</LinearLayout>
</LinearLayout>
看了一些资料,发现有可能是<LinearLayout>标签不能嵌套使用的问题,去掉里面那个LinearLayout,发现还是有问题,接着去掉了android:layout_marginRight="@+id/save",程序运行正常,这问题蛮坑爹的,<android:layout_marginRight="@+id/save"
>居然不支持嵌套,这个问题还有待深究。
接下来,我又加上那个LinearLayout,然后只去掉,<android:layout_marginRight="@+id/save">,发现也好了,由此证明LinearLayout是可以嵌套的,应该是layout_marginRight这个属性有问题导致的。
06-03 03:23:27.289: E/AndroidRuntime(9939): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.zuo.txt/com.zuo.txt.EditPage}: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12
绞尽脑汁,也没想出哪里有问题,页面代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:staggered="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="@color/edit_select"
android:orientation="vertical" >
<TextView
android:id="@+id/spinner_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="25sp"
android:textColor="#ff0000" />
<LinearLayout
android:id="@+id/relativeLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/edit_select">
<Spinner
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="5"
android:layout_marginLeft="10dp"
android:background="@drawable/shape"
android:textSize="12sp"
/>
<ImageButton
android:id="@+id/ib_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="@+id/spinner"
android:layout_marginEnd="@+id/spinner"
android:background="@drawable/imbutton"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:contentDescription="isearch"
android:src="@drawable/ic_search" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/edit_select"
android:orientation="horizontal" >
<com.origamilabs.library.views.StaggeredGridView
android:id="@+id/staggeredGridView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
staggered:drawSelectorOnTop="true"
staggered:numColumns="2" />
</LinearLayout>
</LinearLayout>
看了一些资料,发现有可能是<LinearLayout>标签不能嵌套使用的问题,去掉里面那个LinearLayout,发现还是有问题,接着去掉了android:layout_marginRight="@+id/save",程序运行正常,这问题蛮坑爹的,<android:layout_marginRight="@+id/save"
>居然不支持嵌套,这个问题还有待深究。
接下来,我又加上那个LinearLayout,然后只去掉,<android:layout_marginRight="@+id/save">,发现也好了,由此证明LinearLayout是可以嵌套的,应该是layout_marginRight这个属性有问题导致的。