安卓 - java.lang.UnsupportedOperationException : Can't convert to dimension: type=0x12

标签 android xml layout android-linearlayout

我正在尝试为我的 android 应用程序制作一个 UI,但它崩溃了,错误是

"java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.test/com.example.test.MainActivity}: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12"

这是我的 XML 代码

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff000000"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin">

    <EditText
        android:id="@+id/symbolName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textCapCharacters"
        android:textColor="#ffffffff" >
    </EditText>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:orientation="vertical" >

        <RadioButton
            android:id="@+id/radioButton1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="RadioButton" />

        <RadioButton
            android:id="@+id/RadioButton01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="RadioButton" />

        <RadioButton
            android:id="@+id/RadioButton02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="RadioButton" />

        <RadioButton
            android:id="@+id/RadioButton03"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="RadioButton" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/condition" 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="@+id/RadioButton03">

        <EditText 
            android:inputType="number"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

    </LinearLayout>

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Add Alert"/>

</LinearLayout>

我做错了什么?有什么想法吗?

最佳答案

您在此行提供的资源无效:

android:layout_marginTop="@+id/RadioButton03"

尺寸应用于边距,例如

android:layout_marginTop="@dimen/margin_top"

关于安卓 - java.lang.UnsupportedOperationException : Can't convert to dimension: type=0x12,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17760574/

相关文章:

Android以编程方式获取可见布局的高度

android - 复选框 Material 设计

java - 如何在SWT中使GridLayout的某些列增长?

xml - 规范 XML : whitespace in element-only container?

iphone - 当再次调用 loadView 时,iOS7 View 在状态/导航栏下移动

Android Studio 库项目不生成 Jar 文件

java - startActivityForResult 带有枚举

android - NDK 未在 android studio 中配置问题

android - 颜色.xml : Error: Unsupported type 'component' (Android studio)

java - 更改方向而不再次加载