나는 안드로이드에서 새로운데, 몇 가지 질문이 있고, 여기에 그들에게 물어보기로 결정했다. 당신이 나를 도울 수 있기를 바랍니다. 미리 감사드립니다.Content_main.xml에 toolbar_main.xml을 넣고 호출하는 방법은 무엇입니까?
먼저 나는 내가 각 도구 모음을 수 있도록 안드로이드 스튜디오 app_bar_main.xml에 content_main.xml
을 app_bar_main.xml
, toolbar_main.xml
및 content_main.xml
을 만들고 참여 내가 기본에 내가 탐색 서랍 활동을 선택하여 새 프로젝트 할 때 문제가있는 페이지,하지만 toolbar (app_bar_main.xml)
을 넣고 싶습니다. content_main.xml
하지만 내 앱을 강제로 닫으면 오류가 많이 생깁니다. 몸이 맞을 때 샘플 코드으로 대답합니까?
이유는 툴바 제목이있는 대화 상자를 사용하고 많은 샘플 코드를 검색하고 테스트 할 때 내 콘텐츠를 특별히 사용자 지정하는 것이지만이 경우에는 아무 것도 작동하지 않으며 앱에서 '제목 없음'을 선택합니다. 도구 모음 제목이 비어있는 장소에 대화 상자가 표시됩니다 (dialog.xml
).
도움 대신 부정적인 점수를 주셔서 감사합니다.
app_bar_main.xml
<android.support.design.widget.CoordinatorLayout ....>
<include layout="@layout/toolbar_main" />
</android.support.design.widget.CoordinatorLayout>
. toolbar_main.xml
<LinearLayout .....>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="right"
android:background="@color/colorPrimary">
<TextView
android:id="@+id/toolbarTitle" ... />
<ImageView
android:id="@+id/imageView"... />
</android.support.v7.widget.Toolbar>
//content
<include layout="@layout/content_main" />
</LinearLayout>
. 당신은 사용할 수 있습니다
<RelativeLayout
......
android:id="@+id/mainContent"
tools:showIn="@layout/app_bar_main">
</RelativeLayout>