1

我对android开发很陌生,所以答案可能很简单。

我在我的项目中使用这个库, https://github.com/jfeinstein10/SlidingMenu

我有我的主布局(activity_main),它有一个显示相机的表面视图。该库使用布局文件(menu_frame)。我的问题是我想将该布局文件覆盖在我的布局(activity_main)之上。因此,不是菜单 (menu_frame) 推送我的布局文件,而是覆盖它并保留我的布局文件。

目的是我想将菜单的不透明度设置为最小,以便在菜单打开时您仍然可以查看它后面的相机。

我调用我的 setcontentview(R.layout.activity_main),然后调用 setbehindcontentview(R.layout.menu_frame)。所以我想如果我给菜单一个id并将menu_frame布局中的framelayout添加到我的activity_main布局中,我将能够调用setbehindcontentview(R.id.framelayoutId),但这不起作用。

这是我的代码片段:

   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       requestWindowFeature(Window.FEATURE_NO_TITLE);


       final int activity = R.layout.activity_main;
       setContentView(activity);

       setBehindContentView(R.layout.menu_frame);

        SlidingMenu sm = getSlidingMenu();
        sm.setShadowWidthRes(R.dimen.shadow_width);
        sm.setShadowDrawable(R.drawable.shadow);
        sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
        sm.setFadeDegree(0.35f);
        sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<SurfaceView
    android:id="@+id/surfaceview"
    android:layout_width="fill_parent"
    android:layout_height="match_parent" />

</FrameLayout>

menu_frame.xml:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF" />

总而言之,我希望一个布局文件覆盖另一个布局文件,或者以一种将它们叠加在彼此之上的方式将两者结合起来。

提前致谢

4

0 回答 0