styling bottom action icon postion and background color

前端 未结 2 1847
轮回少年
轮回少年 2020-12-22 08:19

I have this bottom action bar style

I want to design like this (left , center, right) with background color blue or red

this is the menu

相关标签:
2条回答
  • 2020-12-22 08:47

    If you have not solved your issue, you can refer to the following:

    activity_main.xml:

    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        tools:context=".MainActivity">
    
        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/AppTheme.AppBarOverlay">
    
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:popupTheme="@style/AppTheme.PopupOverlay" />
    
        </android.support.design.widget.AppBarLayout>
    
        <include layout="@layout/content_main" />
    
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar_bottom"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:layout_alignParentBottom="true"
                android:background="?attr/colorPrimary"
                app:popupTheme="@style/AppTheme.PopupOverlay">
    
                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content">
    
                    <ImageButton
                        android:id="@+id/button1"
                        android:layout_width="10dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="0.175"
                        android:background="@android:color/transparent"
                        android:src="@drawable/ic_action_back" />
    
                    <View
                        android:id="@+id/view1"
                        android:layout_width="0dp"
                        android:layout_height="0dp"
                        android:layout_weight="0.1" />
    
                    <ImageButton
                        android:id="@+id/button2"
                        android:layout_width="10dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="0.175"
                        android:background="@android:color/transparent"
                        android:src="@drawable/ic_action_cloud" />
    
                    <View
                        android:id="@+id/view2"
                        android:layout_width="0dp"
                        android:layout_height="0dp"
                        android:layout_weight="0.1"
                        android:background="@android:color/transparent" />
    
                    <ImageButton
                        android:id="@+id/button3"
                        android:layout_width="10dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="0.175"
                        android:background="@android:color/transparent"
                        android:src="@drawable/ic_action_copy" />
    
                    <View
                        android:id="@+id/view3"
                        android:layout_width="0dp"
                        android:layout_height="0dp"
                        android:layout_weight="0.1"
                        android:background="@android:color/transparent" />
    
                    <ImageButton
                        android:id="@+id/button4"
                        android:layout_width="10dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="0.175"
                        android:background="@android:color/transparent"
                        android:src="@drawable/ic_action_help" />
    
                </LinearLayout>
    
            </android.support.v7.widget.Toolbar>
    
        </RelativeLayout>
    
    </android.support.design.widget.CoordinatorLayout>
    

    0 讨论(0)
  • 2020-12-22 08:57

    Here you can download the needed icons: https://www.google.com/design/icons/index.html

    The distance between the icons can you make with a custom android:actionButtonStyle like:

    <item name="android:actionButtonStyle">@style/ActionButtonStyle</item>
    
    <style name="ActionButtonStyle" parent="@android:style/Widget.Holo.Light.ActionButton">
        <item name="android:minWidth">70dip</item>
        <item name="android:paddingLeft">70dip</item>
        <item name="android:paddingRight">70dip</item>                  
    </style>
    

    And the background color:

    ActionBar bar = getActionBar();
    bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#FF0000")));
    
    0 讨论(0)
提交回复
热议问题