相关疑难解决方法(0)

导航抽屉(menudrawer)Android 5(棒棒糖)风格

我用我的项目menudrawer库(这一个:https://github.com/SimonVT/android-menudrawer).

我正在更新我的应用程序以与API21(Android 5 Lollipop)和Material Design兼容.当你在API21中使用这个库时,menudrawer图标看起来很糟糕.

我希望在新的Play商店中实现转换(新的menudrawer图标转换为箭头).

Play商店导航抽屉图标

最好的方法是什么?这个图书馆可以吗?我现在想到的唯一解决方案是自定义绘图.但也许我可以用某种方式使用原生的drawable?

android drawable navigation-drawer android-5.0-lollipop

13
推荐指数
2
解决办法
3万
查看次数

用support.v7版本替换已弃用的android.support.v4.app.ActionBarDrawerToggle导致抽屉不适用于Jelly Bean

继在回答这个问题,我已经更换ActionBarDrawerToggle 支持V4库,在最新的更新(启21)已经被弃用了最新ActionBarDrawerTogglesupport-v7 library.

现在,抽屉在Andrid Lollipop Emulator上工作,没有弃用警告但是当我在Jelly Bean真实设备上测试应用程序时,没有显示抽屉和切换抽屉按钮.

这个支持库更新到底是什么?如果不降级到以前的版本,我怎么能解决这个问题?

在这里我的布局

<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" >

    <!--  content view -->

    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context=".MainActivity" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/drawer_text" />
    </RelativeLayout>

    <!-- nav drawer -->

    <ListView
        android:id="@+id/drawer"
        android:layout_width="320dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="#F3F3F4"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp" />

</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

android android-support-library

11
推荐指数
1
解决办法
2万
查看次数

通过操作栏标题切换导航抽屉

我试图通过点击操作栏标题(这是当前Android Gmail应用程序的设置方式)允许用户在我的应用中打开/关闭导航抽屉.此时,用户可以通过点击应用程序/抽屉图标或通过左右滑动将其滑入来切换抽屉.但是,操作栏标题本身不可单击.根据开发人员文档,当我们使用时,单击操作栏标题应该" onOptionsItemSelected使用带有项目ID的MenuItem 调度到主机Activity android.R.id.home",NAVIGATION_MODE_STANDARD但由于某种原因,我无法通过这种方式获得标题.

我相信导航抽屉本身很好,但这是我如何设置动作栏:

private void configureActionBar(CharSequence mTitle) {

    ActionBar actionBar = getActionBar();

    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    actionBar.setIcon(R.drawable.ic_blank);

    GradientDrawable gd = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
                new int[] {
                0xFF004700, 0xFF002900
                });

    gd.setCornerRadius(0f);

    actionBar.setBackgroundDrawable(gd);

    // set the title of the action bar using the given title
    actionBar.setTitle(mTitle);

}
Run Code Online (Sandbox Code Playgroud)

任何建议将不胜感激!

gmail android toggle android-actionbar navigation-drawer

8
推荐指数
1
解决办法
2万
查看次数

不推荐使用ActionBarDrawerToggle

我试图在我的应用程序中实现android.support.v4.app.ActionBarDrawerToggle; 因为这个类已被弃用

不推荐使用此类.请在support-v7-appcompat中使用ActionBarDrawerToggle.

我已切换到android.support.v7.app.ActionBarDrawerToggle.

在我以这种方式调用构造函数之前:

mDrawerToggle = new ActionBarDrawerToggle(
    this,                  /* host Activity */
    mDrawerLayout,         /* DrawerLayout object */
    R.drawable.ic_drawer,  /* nav drawer image to replace 'Up' caret */
    R.string.drawer_open,  /* "open drawer" description for accessibility */
    R.string.drawer_close  /* "close drawer" description for accessibility */
){
    public void onDrawerClosed(View view) {
        getActionBar().setTitle(mTitle);
        invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
    }

    public void onDrawerOpened(View drawerView) {
        getActionBar().setTitle(mDrawerTitle);
        invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
    }
};
Run Code Online (Sandbox Code Playgroud)

但在我切换到较新的v7支持库后,我收到错误

"ActionBarDrawerToggle() in ActionBarDrawerToggle cannot be applied …
Run Code Online (Sandbox Code Playgroud)

android navigation-drawer actionbardrawertoggle

8
推荐指数
1
解决办法
2万
查看次数