Android工具栏右侧的导航抽屉汉堡包图标

时间:2016-10-03 13:21:09

标签: android android-layout android-appcompat

如何将导航抽屉汉堡包图标放在Android工具栏的右侧? 我用Gravity.RIGHT更改抽屉打开/关闭方向,但汉堡包切换按钮仍然在工具栏的左侧。

这是我的工具栏代码:

//Function Call
UIColor *organizationColor = [self colorWithHexString:@"#AAAAAAAAAAAAA" alpha:1];

//Function
- (UIColor *)colorWithHexString:(NSString *)str_HEX  alpha:(CGFloat)alpha_range{
    NSString *noHashString = [str_HEX stringByReplacingOccurrencesOfString:@"#" withString:@""]; // remove the #

    int red = 0;
    int green = 0;
    int blue = 0;

if ([str_HEX length]<=3)
    {
        sscanf([noHashString UTF8String], "%01X%01X%01X", &red, &green, &blue);
        return  [UIColor colorWithRed:red/16.0 green:green/16.0 blue:blue/16.0 alpha:alpha_range];
    }
else if ([str_HEX length]>7)
    {
        NSString *mySmallerString = [noHashString substringToIndex:6];
        sscanf([mySmallerString UTF8String], "%02X%02X%02X", &red, &green, &blue);
        return  [UIColor colorWithRed:red/255.0 green:green/255.0 blue:blue/255.0 alpha:alpha_range];
    }
else
{
    sscanf([noHashString UTF8String], "%02X%02X%02X", &red, &green, &blue);
    return  [UIColor colorWithRed:red/255.0 green:green/255.0 blue:blue/255.0 alpha:alpha_range];
}}

我的抽屉代码是:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    app:elevation="@dimen/default_elevation"
    app:layout_scrollFlags="scroll|enterAlways"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <ImageView
        android:id="@+id/ivLogo"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:scaleType="center"
        android:src="@drawable/img_toolbar_logo" />
</android.support.v7.widget.Toolbar>

这是我的 baseDrawer活动

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

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawerLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <FrameLayout
            android:id="@+id/flContentRoot"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <android.support.design.widget.NavigationView
            android:id="@+id/vNavigation"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:background="#ffffff"
            app:headerLayout="@layout/view_global_menu_header"
            app:itemIconTint="#8b8b8b"
            app:itemTextColor="#666666"
            app:menu="@menu/drawer_menu" />

    </android.support.v4.widget.DrawerLayout>
</LinearLayout>

0 个答案:

没有答案
相关问题