Unsupportedoperationexception: Can't Convert to Dimension: Type=0X1

UnsupportedOperationException: Can't convert to dimension: type=0x1

After 2 days I found the solution; from the layout as defined in my question, I have a Spinner which is bound with a custom TextView:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listTextViewSpinner"
...
android:textSize="@dimen/spinner_list_item_text_size"
... />

Here, I have an extracted dimension resource: @dimen/spinner_list_item_text_size.

This has been defined in dimens.xml in the following directories:

  • values-sw600dp
  • values-sw720dp-land

but crucially I forgot to define it in

  • values

After defining the resource (@dimen/spinner_list_item_text_size) in values/dimens.xml,it works successfully.

Can't convert to dimension: type=0x1 when inflating the layout

I've found that i lack of value in dimens.xml file. So it cause error

Error: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x3

You need to define your dimensional resources as dimens not strings. So, move your @string/marginbutton from strings.xml to res/values/dimens.xml as

<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen
name="marginbutton">8dp</dimen>
</resources>

Your error basically complains about passing a <string> resource where a <dimen> is expected.

Can't convert to dimension: type=0x1 when running app on Android 4.1

Always look at the API Level for an attribute:

<RelativeLayout
...
...
android:layout_alignParentEnd="false"/>

android:layout_alignParentEnd was added in API level 17

http://developer.android.com/reference/android/widget/RelativeLayout.html#ALIGN_PARENT_END

How to resolve UnsupportedOperationException: Can't convert to dimension: type=0x12

Check your margin start values at below lines

 android:layout_marginStart="@+id/txtCreatedOnStart"
android:layout_marginStart="@+id/txtPausedOnResume"

Try giving dp values

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

You should add android:windowTranslucentNavigation attribute in values-v19 style.

It is not supported in older versions.

java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12 in android

Remove android:layout_marginLeft="@+id/option2" from your option4 RadioButton.As you cannot give any view as margin.And also make your alignment view ids as @+id and not @id

Try below data :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:id="@+id/question"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:text="what is your name?"
android:textColor="@android:color/black" />

<RadioGroup
android:id="@+id/answer_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/question"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp" >

<RelativeLayout
android:id="@+id/radio_group_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<RadioButton
android:id="@+id/option1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="paru"
android:textColor="@android:color/black" />

<RadioButton
android:id="@+id/option2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_toRightOf="@+id/option1"
android:text="mani"
android:textColor="@android:color/black" />

<RadioButton
android:id="@+id/option3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/option1"
android:text="sankar"
android:textColor="@android:color/black" />

<RadioButton
android:id="@+id/option4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/option2"
android:layout_toRightOf="@+id/option3"
android:text="venkat"
android:textColor="@android:color/black" />
</RelativeLayout>
</RadioGroup>

</RelativeLayout>


Related Topics



Leave a reply



Submit