java.lang.UnsupportedOperationException:引起无法转换为维度:类型= 0×12 [英] Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12
本文介绍了java.lang.UnsupportedOperationException:引起无法转换为维度:类型= 0×12的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我正在开发的应用程序。我的完美的应用在所有devices.But运行当我们运行于mdpi手机上这个应用程序的让我这个错误:
Hi I am developing application .My application run perfectly on all devices.But when we run this application on mdpi phone its getting me this error:
产生的原因:java.lang.UnsupportedOperationException:不能转换为维度:类型= 0×12
请帮我在哪里,我错了。
Kindly help me where i am wrong.
这是我的code: -
This is My Code:-
<RelativeLayout
android:id="@+id/LevLayId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="140dp" >
<TextView
android:id="@+id/totlScorId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="@drawable/score_timer"
android:gravity="center"
android:textColor="#ffffff" />
<TextView
android:id="@+id/levelId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@drawable/score_timer"
android:gravity="center"
android:textColor="#ffffff" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/LayAboButId"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/option_last_row"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="7px"
android:orientation="horizontal" >
<Button
android:id="@+id/opt3Btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/option_normal_new"
android:gravity="center|center_vertical"
android:textColor="#ffffff"
android:textSize="11dp" />
<Button
android:id="@+id/opt4Btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/option_normal"
android:gravity="center|center_vertical"
android:textColor="#ffffff"
android:textSize="11dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/option_pre_row"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/option_last_row"
android:layout_marginBottom="3px"
android:orientation="horizontal" >
<Button
android:id="@+id/opt1Btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/option_normal_new"
android:gravity="center|center_vertical"
android:textColor="#ffffff"
android:textSize="11dp" />
<Button
android:id="@+id/opt2Btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/option_normal"
android:gravity="center|center_vertical"
android:textColor="#ffffff"
android:textSize="11dp" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/imgLayId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dp"
android:layout_marginRight="@id/totlScorId"
android:layout_marginTop="70dp" >
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<ImageView
android:id="@+id/imgViewId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<ImageView
android:id="@+id/imgViewframeId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/photo_frame" />
</RelativeLayout>
推荐答案
使用一个父布局和使用下面的XML code,而不是你的code,它会解决你的问题。
Use one Parent layout and Use below XML code instead of your code, it will solve your problem.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android1="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="@+id/LevLayId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="140dp" >
<TextView
android:id="@+id/totlScorId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="@drawable/score_timer"
android:gravity="center"
android:textColor="#ffffff" />
<TextView
android:id="@+id/levelId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@drawable/score_timer"
android:gravity="center"
android:textColor="#ffffff" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/LayAboButId"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/option_last_row"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="7px"
android:orientation="horizontal" >
<Button
android:id="@+id/opt3Btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/option_normal_new"
android:gravity="center|center_vertical"
android:textColor="#ffffff"
android:textSize="11dp" />
<Button
android:id="@+id/opt4Btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/option_normal"
android:gravity="center|center_vertical"
android:textColor="#ffffff"
android:textSize="11dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/option_pre_row"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/option_last_row"
android:layout_marginBottom="3px"
android:orientation="horizontal" >
<Button
android:id="@+id/opt1Btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/option_normal_new"
android:gravity="center|center_vertical"
android:textColor="#ffffff"
android:textSize="11dp" />
<Button
android:id="@+id/opt2Btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/option_normal"
android:gravity="center|center_vertical"
android:textColor="#ffffff"
android:textSize="11dp" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/imgLayId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dp"
android:layout_marginRight="@id/totlScorId"
android:layout_marginTop="70dp" >
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<ImageView
android:id="@+id/imgViewId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<ImageView
android:id="@+id/imgViewframeId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/photo_frame" />
</RelativeLayout>
</RelativeLayout>
这篇关于java.lang.UnsupportedOperationException:引起无法转换为维度:类型= 0×12的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文