2

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

4

1 回答 1

4

我认为这是因为您的 left_drawer 没有背景:

<!-- 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"/>
于 2013-07-18T11:21:13.947 回答