Ankur February 2016

android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.GridLayout

This error comes when I am running the app.

java.lang.RuntimeException: Unable to start activity ComponentInfo : android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.GridLayout

<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context="com.example.ankur.shop.HomeActivity"
    android:background="@drawable/gradient7">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Welcome"
        android:id="@+id/welcomeText"
        android:layout_row="0"
        android:layout_column="0" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/nameText"
        android:layout_row="0"
        android:layout_column="1" />

    <ViewFlipper
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/viewFlipper"
        android:layout_row="1"
        android:layout_column="0"
        android:inAnimation="@color/abc_color_highlight_material"
        android:flipInterval="@integer/abc_config_activityDefaultDur">

        <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/picture1" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/picture2" />

    <ImageView
        android:layout_widt        

Answers


Shree Krishna February 2016

As the documentation, you must be aware that App Widget layouts are based on RemoteViews, which do not support every kind of layout or view widget.

May be your GridView is not allowed where you are trying to use that. A RemoteViews object can support the following layout classes:

  • FrameLayout
  • LinearLayout
  • RelativeLayout
  • GridLayout

See more at here

Solution

  • Try using another layout type in your remote view.
  • You probably using prior than 4.2. which may not support, review that too.

Post Status

Asked in February 2016
Viewed 1,323 times
Voted 7
Answered 1 times

Search




Leave an answer