현재 툴바 및 DrawerLayout을 사용하여 Android 앱을 개발 중입니다. 주요 내용은 다른 모양, 텍스트를 그릴 수있는 사용자 지정 SurfaceView입니다. 왼쪽 메뉴는 NavigationView이며 도구 상자로 사용됩니다 (왼쪽에서 그리려는 항목을 선택하고 SurfaceView에서 그립니다). 한 가지를 제외하고는 모든 것이 잘 작동합니다. 도구 모음을 클릭하거나 화면의 왼쪽에서 밀어 왼쪽 메뉴를 열려고 할 때 항목이 보이지 않습니다. 그리고 어떤 항목 (보이지 않음)을 클릭하지는 않지만 보이지 않습니다. 보이지 않는 항목을 클릭하면 메뉴가 정상적으로 작동하는 경우에만 문제가 해결됩니다. 나는 상태 표시 줄을 숨기고 기본 액션 바 제거하기 위해 사용자 지정 테마를 사용하고 있습니다 : 스크린 샷은 여기안드로이드 - 처음 열 때 DrawerLayout 및 툴바가 표시되지 않습니다.
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.NoActionBar"></style>
<style name="ColladiaTheme" parent="AppBaseTheme">
<!-- Remove action bar -->
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<!-- Remove status bar -->
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
<!-- Material theme -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
입니다 : 여기
Menu visible after clicking an item
<?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" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.ia04nf28.colladia.DrawColladiaView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/draw_view" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="?attr/actionBarSize"
android:layout_width="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary">
</android.support.v7.widget.Toolbar>
</FrameLayout>
<!-- Left navigation menu -->
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="?attr/actionBarSize"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:layout_gravity="start"
android:fitsSystemWindows="false"
app:menu="@menu/nav_view_items" >
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
그리고 활동 코드 :
당신의 서랍 이제까지 개방되는 위치@Override
public boolean onOptionsItemSelected(MenuItem item) {
// This will toggle the drawer if android.R.id.home is clicked
if(drawerToggle.onOptionsItemSelected(item)) {
return true;
}
// Handle any other menu item selections...
return super.onOptionsItemSelected;
}
는 솔직히 말해서, 나는 보이지 않는 : 당신이 onBackPressed
대신 onOptionsItemSelected
를 재정의해야처럼210
은}
아무것도 당신의 XML에 잘못된 것으로 나에게 점프하지, 당신의 활동 코드와 함께 할 수있는 뭔가가있을 수 있습니다. – Bryan
@ 브라이언, 내 질문을 편집하고 내 활동 코드를 추가했습니다 – Bash