2017-05-23 3 views
1

내비게이션 서랍 "BaseActivity"를 여러 액티비티로 확장하도록 만들었지 만 내비게이션 서랍을 열 때 아무 것도 클릭 할 수 없으며 반투명 한 레이어가 있습니다. 그들이로드 된 z- 순서가 나에게 제안하는 것들이 부정확합니다. 어떻게 해결할 수 있을까요?Android : 내비게이션 서랍 Z- 색인이 잘못됨

이미지를 게시 할 담당자가 충분하지 않습니다! http://imgur.com/a/IT9LI

activity_base.xml

<?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_base" 
    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_navigation" 
    app:menu="@menu/activity_base_drawer"/> 
</android.support.v4.widget.DrawerLayout> 

content_base.xml

<android.support.v4.widget.DrawerLayout 
    android:id="@+id/activity_container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto"> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 
    <FrameLayout 
     android:id="@+id/activity_content" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

</LinearLayout> 
<android.support.design.widget.NavigationView 
    android:id="@+id/navigationView" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    app:menu="@menu/activity_base_drawer"/> 
</android.support.v4.widget.DrawerLayout> 

baseactivity.java

package com.example.SNIPCONFIDENTIAL; 

    import android.content.Intent; 
    import android.support.annotation.LayoutRes; 
    import android.support.design.widget.NavigationView; 
    import android.support.v4.view.GravityCompat; 
    import android.support.v4.widget.DrawerLayout; 
    import android.support.v7.app.ActionBarDrawerToggle; 
    import android.support.v7.app.AppCompatActivity; 
    import android.support.v7.widget.Toolbar; 
    import android.view.MenuItem; 
    import android.view.View; 
    import android.widget.FrameLayout; 

    public class BaseActivity extends AppCompatActivity implements 
    NavigationView.OnNavigationItemSelectedListener { 

    private NavigationView navigationView; 
    private DrawerLayout fullLayout; 
    private Toolbar toolbar; 
    private ActionBarDrawerToggle drawerToggle; 
    private int selectedNavItemId; 

    @Override 
    public void setContentView(@LayoutRes int layoutResID) { 

    fullLayout = (DrawerLayout) 
    getLayoutInflater().inflate(R.layout.activity_base, null); 

    FrameLayout activityContainer = (FrameLayout) 
    fullLayout.findViewById(R.id.activity_content); 
    getLayoutInflater().inflate(layoutResID, activityContainer, true); 


    super.setContentView(fullLayout); 

    toolbar = (Toolbar) findViewById(R.id.toolbar); 
    navigationView = (NavigationView) 
    findViewById(R.id.navigationView); 

    if (useToolbar()) 
    { 
     setSupportActionBar(toolbar); 
    } 
    else 
    { 
     toolbar.setVisibility(View.GONE); 
    } 

    setUpNavView(); 
} 

@Override 
public void onBackPressed() { 
    DrawerLayout drawer = (DrawerLayout) 
    findViewById(R.id.drawer_layout); 
    if (drawer.isDrawerOpen(GravityCompat.START)) { 
     drawer.closeDrawer(GravityCompat.START); 
    } else { 
     super.onBackPressed(); 
    } 
} 

    /* @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
    // Inflate the menu; this adds items to the action bar if it is 
    present. 
    getMenuInflater().inflate(R.menu.base, menu); 
    return true; 
}*/ 

@Override 
public boolean onOptionsItemSelected(MenuItem item) { 
    // Handle action bar item clicks here. The action bar will 
    // automatically handle clicks on the Home/Up button, so long 
    // as you specify a parent activity in AndroidManifest.xml. 
    int id = item.getItemId(); 

    //noinspection SimplifiableIfStatement 
    /*if (id == R.id.action_settings) { 
     return true; 
    }*/ 

    return super.onOptionsItemSelected(item); 
} 

@SuppressWarnings("StatementWithEmptyBody") 
@Override 
public boolean onNavigationItemSelected(MenuItem item) { 
    // Handle navigation view item clicks here. 
    int id = item.getItemId(); 

    if (id == R.id.nav_camera) { 
     // Handle the camera action 
     Intent myIntent = new Intent(BaseActivity.this, 
     createmytimetable_days.class); 
     //myIntent.putExtra("key", value); //Optional parameters 
     BaseActivity.this.startActivity(myIntent); 

    } else if (id == R.id.nav_gallery) { 

    } else if (id == R.id.nav_slideshow) { 

    } else if (id == R.id.nav_manage) { 

    } else if (id == R.id.nav_share) { 

    } else if (id == R.id.nav_send) { 

    } 

    DrawerLayout drawer = (DrawerLayout) 
    findViewById(R.id.drawer_layout); 
    drawer.closeDrawer(GravityCompat.START); 
    return true; 
} 

//STUFF FOR ADDING A BUTTON TO THE TOOLBAR 
protected boolean useToolbar() 
{ 
    return true; 
} 

//STUFF FOR ADDING A BUTTON TO THE TOOLBAR 
protected void setUpNavView() { 
    navigationView.setNavigationItemSelectedListener(this); 

    if(useDrawerToggle()) { // use the hamburger menu 
     drawerToggle = new ActionBarDrawerToggle(this, fullLayout, 
toolbar, 
       R.string.navigation_drawer_open, 
       R.string.navigation_drawer_close); 

     fullLayout.addDrawerListener(drawerToggle); 
     drawerToggle.syncState(); 
    } else if(useToolbar() && getSupportActionBar() != null) { 
     // Use home/back button instead 
     getSupportActionBar().setDisplayHomeAsUpEnabled(true); 
     getSupportActionBar().setHomeAsUpIndicator(getResources() 
       .getDrawable(R.drawable.ic_menu_send)); 
    } 
} 

//STUFF FOR ADDING A BUTTON TO THE TOOLBAR 
protected boolean useDrawerToggle() 
{ 
    return true; 
} 


} 
+0

왜 두 개의 'NavigationView'가 있습니까? –

+0

안녕하세요 @VeneetReddy, 확실하지 방법에 그 미끄러 - 지금 삭제. 그래서 순간에는 메뉴의 링크를 클릭 할 수 있지만 세미 불투명 한 레이어는 메뉴 항목의 맨 위에 남아 있습니다. 나는 명백한 것을 놓치고 있는가? (실례 초급 질문 :) –

답변

0

당신이 말한대로 문제가 Z-인덱스의 경우, 당신은 bringToFront()을 사용하여 항상이 방법을 DrawerL에 호출 할 수 있습니다. ayout 또는 NavigationView!