关于LinearLayout属性android:layout_marginRight的错误

今天写程序,从一个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这个属性有问题导致的。 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值