仅在Samsung Galaxy Note Edge(Android 5.0.1)上,我得到了android.view.InflateException:二进制XML文件第23行:错误膨胀了类android.support.design.widget.AppBarLayout)。
当前我正在使用支持库版本27.1.1
implementation "com.android.support:design:27.1.1"
在我也使用支持库版本26之前,但没有成功。
我在相应的活动中使用了以下主题:
<style name="ToolbarTheme" parent="Theme.AppCompat"> <item name="windowNoTitle">true</item> <item name="windowActionBar">false</item> <item name="actionMenuTextColor">@android:color/white</item> <item name="android:actionMenuTextColor">@android:color/white</item> <item name="textAllCaps">false</item> </style>
StackTrace:
09-13 09:56:43.378 3975 3975 FATAL [main,pri=-11] SourceFile:1280: Uncaught exception in Thread[main,5,main]
09-13 09:56:43.378 3975 3975 FATAL [main,pri=-11] java.lang.RuntimeException: Unable to start activity ComponentInfo{com.messaging.vzmsgs/com.messaging.mqtt.group.ui.CreateGroupActivity}: android.view.InflateException: Binary XML file line #23: Error inflating class android.support.design.widget.AppBarLayout
09-13 09:56:43.378 3975 3975 FATAL [main,pri=-11] android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2712)
09-13 09:56:43.378 3975 3975 FATAL [main,pri=-11] android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2777)
09-13 09:56:43.378 3975 3975 FATAL [main,pri=-11] android.app.ActivityThread.access$900(ActivityThread.java:179)
09-13 09:56:43.378 3975 3975 FATAL [main,pri=-11] android.app.ActivityThread$H.handleMessage(ActivityThread.java:1462)
09-13 09:56:43.378 3975 3975 FATAL [main,pri=-11] android.os.Handler.dispatchMessage(Handler.java:102)
09-13 09:56:43.378 3975 3975 FATAL [main,pri=-11] android.os.Looper.loop(Looper.java:145)
09-13 09:56:43.378 3975 3975 FATAL [main,pri=-11] android.app.ActivityThread.main(ActivityThread.java:5972)
09-13 09:56:43.378 3975 3975 FATAL [main,pri=-11] java.lang.reflect.Method.invoke(Native Method)
09-13 09:56:43.378 3975 3975 FATAL [main,pri=-11] java.lang.reflect.Method.invoke(Method.java:372)
09-13 09:56:43.378 3975 3975 FATAL [main,pri=-11] com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
09-13 09:56:43.378 3975 3975 FATAL [main,pri=-11] com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
09-13 09:56:43.378 3975 3975 FATAL [main,pri=-11] caused by:
09-13 09:56:43.378 3975 3975 FATAL [main,pri=-11] android.view.InflateException: Binary XML file line #23: Error inflating class android.support.design.widget.AppBarLayout
布局代码:
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#e5e5e5">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
android:fitsSystemWindows="true">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:layout_margin="5dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/group_bg">
<ImageView
android:id="@+id/group_icon"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center_horizontal"
android:src="@drawable/ico_add_group_img_white"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal">
<com.aniways.AniwaysEditText
android:id="@+id/group_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:hint="@string/create_group_name_hint_txt"
android:maxWidth="@dimen/maxTextMessageWidth"
android:inputType="textCapSentences"
android:textColor="@android:color/black"
android:textColorHint="#a1a1a0"
android:textStyle="italic"
android:gravity="center"
android:cursorVisible="true"
android:textCursorDrawable="@null"
android:textSize="17dp"
android:theme="@android:style/Theme.Holo.Light.NoActionBar"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
<ImageView
android:id="@+id/btnEmoji"
android:layout_width="23dp"
android:layout_height="23dp"
android:contentDescription="@string/add_emoji"
android:src="@drawable/emoji_active_chooser"
android:layout_marginLeft="15dp"
android:layout_centerVertical="true"
android:visibility="gone"
android:layout_toRightOf="@+id/group_name" />
</RelativeLayout>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="0.7dp"
android:layout_below="@+id/group_name"
android:layout_marginTop="10dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:background="#c3c3c3" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
>
<com.verizon.messaging.mqtt.group.ui.GroupRightChooser
android:id="@+id/group_right_chooser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
/>
<ImageView
android:id="@+id/admin_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/info"
android:padding="4dp"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/group_right_chooser"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
>
<TextView
android:id="@+id/enhancedgroupInfoText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginBottom="5dp"
android:text="@string/enhanced_group_info_bar"
android:textColor="@color/black"/>
<ImageView
android:id="@+id/enhancedgroupInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_toRightOf="@id/enhancedgroupInfoText"
android:padding="4dp"
android:src="@drawable/info"
/>
</RelativeLayout>
</LinearLayout>
<ImageView
android:id="@+id/select_group_bg"
android:layout_width="20dp"
android:layout_height="20dp"
android:visibility="gone"
android:layout_gravity="right|top"
android:src="@drawable/ico_pencil"
android:layout_margin="10dp"/>
</FrameLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/emoji_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:orientation="vertical"
android:visibility="invisible" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="1dp"
android:id="@+id/contactsContainer"
android:orientation="vertical"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:background="@android:color/white">
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
任何帮助或指导将不胜感激。
答案 0 :(得分:0)
尝试更改此内容:
Theme.AppCompat
收件人:
Theme.AppCompat.Light.NoActionBar
或者您可以尝试在AndroidManifest.xml
中添加它:
android:theme="@style/Theme.AppCompat.Light.NoActionBar"