Android UnsupportedOperationException异常

本文介绍了一个在Android应用程序中遇到的布局加载错误,并给出了具体的解决办法。该错误与使用不支持的属性有关,通过删除问题属性使应用恢复正常。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

从一个Activity跳到另一个Activity,页面加载时出现了以下错误:java.lang.RuntimeException: Unable to start activity ComponentInfo{cn.bzu.mydiary/cn.bzu.mydiary.LoginActivity1}: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12

页面源码为:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/login"
    android:orientation="vertical"
    tools:content=".LoginActivity1" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/login"
        android:textColor="#7FFFD4" />

 	 <EditText
        android:id="@+id/uname"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/password"
        android:textColor="#7FFFD4" />

    <EditText
        android:id="@+id/upass"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>
    <Button
        android:id="@+id/yes"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/login" />

    <Button
        android:id="@+id/no"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@id/yes"
        android:text="@string/quxiao" />

</LinearLayout>


找了很多资料最终解决,由于android:layout_marginLeft属性的问题,只要删除页面设计中的带有其的语句即可正常运行。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值