android - 滑动菜单空白

标签 android

我在我的项目中使用 jfeinstein10 滑动菜单库并且一切正常,只是当我在某些设备上运行我的应用程序时,在包含 ListView 的 fragment 顶部有一个空白区域,这是一张照片:

enter image description here

这是我设置滑动菜单的代码:

    setBehindContentView(R.layout.menu_frame);
    FragmentTransaction fragTransaction = mFragmentManager.beginTransaction();
    fragMenu = new FragmentMenu();
    fragTransaction.replace(R.id.menu_frame, fragMenu);
    fragTransaction.commit();

    SlidingMenu sm = getSlidingMenu();
    sm.setShadowWidthRes(R.dimen.shadow_width);
    sm.setShadowDrawable(R.drawable.shadow);
    sm.setBehindOffsetRes(R.dimen.actionbar_home_width);
    setSlidingActionBarEnabled(true);

    final ActionBar mActionBar = getSupportActionBar();
    mActionBar.setHomeButtonEnabled(true);
    mActionBar.setDisplayHomeAsUpEnabled(true);

这将是我的 fragment 布局的 XML 文件:

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

<ExpandableListView
    android:id="@+id/expListView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:cacheColorHint="@color/fondoRowsMenuIzquierdo"
    android:childDivider="@color/fondoRowsChildMenuIzquierdo"
    android:choiceMode="singleChoice"
    android:divider="@color/separadoresMenuIzquierdo"
    android:dividerHeight="1dp"
    android:drawSelectorOnTop="true"
    android:groupIndicator="@null" />

</LinearLayout>

有谁知道如何删除那个空白区域?

最佳答案

我更新到最新的 SlidingMenu 库解决了这个问题:https://github.com/jfeinstein10/SlidingMenu .但此更新带来了另一个问题。

在SlidingMenu.java中有这样一段代码:

public void manageLayers(float percentOpen) {
    if (Build.VERSION.SDK_INT < 11) return;

    boolean layer = percentOpen > 0.0f && percentOpen < 1.0f;
    final int layerType = layer ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE;

    if (layerType != getContent().getLayerType()) {
        mHandler.post(new Runnable() {
            public void run() {
                Log.v(TAG, "changing layerType. hardware? " + (layerType == View.LAYER_TYPE_HARDWARE));
                getContent().setLayerType(layerType, null);
                getMenu().setLayerType(layerType, null);
                if (getSecondaryMenu() != null) {
                    getSecondaryMenu().setLayerType(layerType, null);
                }
            }
        });
    }

如果您在 HONEYCOMB 或以前的 API 版本中使用此库,此代码将不允许您与滑动菜单中的 View 交互,您必须更改此验证:

if (Build.VERSION.SDK_INT < 11) return;

为此:

if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR2)return;

关于android - 滑动菜单空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15624803/

相关文章:

java - 如何在Android上使用标记上的信息窗口实现开放街道 map ?

java - Android 检查字符串单词前是否包含数字

android - 如何以编程方式调用android中的帐户设置

android - 正面相机图像失真

java - AndEngine 游戏中的延迟问题,Heap DDMS 解决方案

Android:如何在 xml 布局中添加开/关指示器

java - 叠加层在 Google MapView 教程 Android 中不起作用

android - 如何显示进度条

android - ImageButton.setVisibility() 问题

android - 在包含布局上使用边距