简体   繁体   中英

Android Navigation Drawer - scrim color over menu

I have problem with scrim color overlaying not only main content but also the menu.

This is my layout:

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The main content view -->
<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
<!-- The navigation drawer -->
<FrameLayout android:id="@+id/left_drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="start"/>
</android.support.v4.widget.DrawerLayout>

Initialization code:

public class Launch extends SherlockFragmentActivity {

private ActionBarDrawerToggle mDrawerToggle;
private DrawerLayout mDrawerLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_launch);

    // menu fragment
    ListFragment menu = new com.sayler.inz.Menu();
    FragmentManager fm = getSupportFragmentManager();
    fm.beginTransaction().replace(R.id.left_drawer, menu).commit();



    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow,
            GravityCompat.START);
    mDrawerLayout.setScrimColor(Color.GREEN);

Screens: With no scrim color and with green: http://www.sarigato.com/android/no_color.png http://www.sarigato.com/android/green.png

I think it's because your left_drawer has no background:

<!-- The navigation drawer -->
<FrameLayout android:id="@+id/left_drawer"
android:layout_width="match_parent"
android:background="#efefef"
android:layout_height="match_parent"
android:layout_gravity="start"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM