Is possible to increase the size of ActionBarDrawerToggle (Drawer menu)?

6.6k views Asked by At

I followed ActionBarDrawerToggle GUIDE

And I know how to show the icon of drawer on Action Bar by using drawerImageRes in this.

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

But the icon looks like so small,

So I want know Is possible to increase the Drawer icon size?

People help me please,

Thanks,

4

There are 4 answers

2
Huy Tower On BEST ANSWER

I found the answer, I need research about Action Bar first.

Add this :

<style name="Theme.white_style" parent="@android:style/Theme.Holo.Light.DarkActionBar">
        <item name="android:actionBarSize">64dp</item>
        <item name="actionBarSize">64dp</item>
</style> 

It worked!

p/s : According to Iconography, define height matched the specification for the action bar icons, which is 32 x 32 dp.

mdpi - 32 dp = 32 px

hdpi - 32 dp * 1.5 = 48 px

xxhdpi - 32 dp * 2 = 64 px

Extra reference

0
Nathan VanBenschoten On

When you construct a new ActionBarDrawerToggle one of the parameters is the drawerImageRes. If you want this resource to be larger, try editing this resource (usually R.drawable.ic_drawer) and increasing its size.

0
Larry Stent On

A great answer implemented which is a slight adjustment from this https://stackoverflow.com/a/40774724/3485872

First you want to create a custom class which extends the Drawable class which creates the hamburger and navigation icons. There are various methods to change the size of either but below are the methods which control the hamburger icon.

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);

}
}

Then to call it from your class simply use:

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

You can define attributes using the following styles. It will produce a larger hamburger button, and Back arrow icon.

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>

<!-- This is the Global style for the NavigationDrawer toggle -->
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
    <!--        Set that the nav buttons will animate -->
    <item name="spinBars">true</item>
    <!--       Set the bar length -->
    <item name="barLength">64dp</item>
    <!--        Set the space between the hamburger button bars -->
    <item name="gapBetweenBars">12dp</item>
    <!--        Set the thickness of the bar -->
    <item name="thickness">@dimen/half_default_gap</item>
    <!--        Set the color of the toggle button -->
    <item name="color">@color/colorToolbarTitleText</item>

    <!-- Here's how you increase the size of the back arrow icon. -->
    <item name="arrowHeadLength">@dimen/one_and_half_default_gap</item>
    <item name="arrowShaftLength">64dp</item>
</style>