前提・実現したいこと
Xamarin.Androidで開発を行っています。
AppBarLayoutにidを付与しようとしていますが、付与すると実行時エラーが発生してしまいます。(app_bar_mainの問題個所)
idを付与しないと、アプリは動作します。
付与しようとしているidに重複はありません。
根本的に勘違いしている箇所があればご指摘いただけないでしょうか。
また、最終的に実現したいことは、
FrameLayout(id:content_frame)のアンカーに、AppBarLayoutを指定しようとしています。
アプリのレイアウト構造として、content_frameにfragmentからviewpager + tabstripのレイアウトを配置していますが、画面上部のAppBarにtabstripが隠れてしまうので、重ならないようにしようとしています。
Android開発の勉強中なので、そもそも根本的に構造が悪い可能性もありますが、
最終的に実現したいことは置いておいて、ひとまずidについて、ご指摘いただけないでしょうか。
以上、よろしくお願いいたします。
(もし、改修でレイアウトを変えてくれなんて言われても、プログラムを破壊せずに作れる気がしませんね。。。)
発生している問題・エラーメッセージ
問題個所 Android.Views.InflateException: Binary XML file line #15: Binary XML file line #15: Error inflating class android.support.design.internal.NavigationMenuItemView
該当のソースコード
activity_main
<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:openDrawer="start"> <include layout="@layout/app_bar_main" android:layout_width="match_parent" android:layout_height="match_parent" /> <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" app:headerLayout="@layout/nav_header_main" app:menu="@menu/activity_main_drawer" /> </android.support.v4.widget.DrawerLayout>
app_bar_main
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:id="@+id/toolbar_layout" ///問題の箇所(付与するとビルド時にエラーとなる) android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:minHeight="?attr/actionBarSize" android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /> </android.support.design.widget.AppBarLayout> <FrameLayout android:id="@+id/content_frame" android:layout_below="@id/toolbar_layout" ///最終的に実現したい箇所(idを認識しないためビルド時は削除している) android:layout_width="match_parent" android:layout_height="match_parent" /> </RelativeLayout>
あなたの回答
tips
プレビュー