android - 是否可以增加 ActionBarDrawerToggle(抽屉菜单)的大小?

标签 android android-actionbar navigation-drawer drawertoggle

我关注了ActionBarDrawerToggle GUIDE

而且我知道如何在 Action Bar 上使用 drawerImageRes 显示抽屉图标。

public ActionBarDrawerToggle (Activity activity, DrawerLayout drawerLayout, int drawerImageRes, int openDrawerContentDescRes, int closeDrawerContentDescRes)

The Activity hosting the drawer drawerLayout

The DrawerLayout to link to the given Activity's ActionBar

drawerImageRes A Drawable resource to use as the drawer indicator

openDrawerContentDescRes A String resource to describe the "open drawer" action for accessibility

closeDrawerContentDescRes A String resource to describe the "close drawer" action for accessibility

但是图标看起来好小,

所以我想知道是否可以增加抽屉图标的大小?

请大家帮帮我,

谢谢,

最佳答案

实现了一个很好的答案,这是对 https://stackoverflow.com/a/40774724/3485872 的轻微调整

首先,您要创建一个自定义类,它扩展了创建汉堡包和导航图标的 Drawable 类。有多种方法可以更改其中任何一个的大小,但以下是控制汉堡包图标的方法。

public class HamburgerDrawable extends DrawerArrowDrawable{

public HamburgerDrawable(Context context){
    super(context);
    setColor(context.getResources().getColor(R.color.white));
}

@Override
public void draw(Canvas canvas){
    super.draw(canvas);

    setBarLength(30.0f);
    setBarThickness(5.0f);
    setGapSize(5.0f);

}
}

然后从您的类中调用它只需使用:

private void increaseHamburgerSize(){
    mDrawerToggle.setDrawerArrowDrawable(new HamburgerDrawable(this));
}

关于android - 是否可以增加 ActionBarDrawerToggle(抽屉菜单)的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23896617/

相关文章:

ios - 我如何在中央 Controller 上显示一个具有透明度的抽屉导航?

Android (JNI/NDK) OpenGL - FPS 显示帮助

java - 在 Android 中获取 javascript 生成的 HTML 代码

java - 如何添加模仿 "my location"-button 的 ImageButton?

Android 如何在操作栏中制作可点击的 Logo 图标?

android - 中心操作栏标题

c# xamarin Error inflating 类 ActionMenuView

android - LinearLayout$LayoutParams 无法转换为 android.support.v4.widget.DrawerLayout$LayoutParams

android - 如何从 Fragment 类中的 AsyncTask 类的 onPostExecute 函数中删除 fragment

android - 避免标记(Google Maps for Android API V2)在点击时以 map 为中心