space between toolbar icon and toolbar title

后端 未结 4 1579
青春惊慌失措
青春惊慌失措 2021-02-07 09:39

I want to put spaces between toolbar icon and toolbar title and also I want to change the color of statusbar in my app as same as the color of to

相关标签:
4条回答
  • 2021-02-07 09:44

    Here adding app:titleMarginStart="32dp" solve.

    pay attention on app prefix

    in context:

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar_main"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:layout_scrollFlags="scroll|enterAlways"
        app:logo="@drawable/ic_launcher"
        app:title="@string/app_name"
        app:titleMarginStart="32dp" />
    
    0 讨论(0)
  • 2021-02-07 09:46

    Use Toolbar default title margin left 16dp And we can change it with app:contentInsetStart="100dp"

    Or if you had a navigation icon,the title marigin left 56+16=72dp defalt, So you can change it with app:contentInsetStartWithNavigation="56dp"

    0 讨论(0)
  • 2021-02-07 09:52

    Option 1: Don't recommend:

    Set title with space before your text. For example " Your title"

    Option 2: Add your custom TextView under your Toolbar and you can custom this TextView in your xml layout or your activity class

    For example:

    <android.support.v7.widget.Toolbar 
            android:id="@+id/toolbar" 
            android:layout_width="match_parent" 
            android:layout_height="?attr/actionBarSize" 
            android:background="#0F6177" 
            app:popupTheme="@style/AppTheme.PopupOverlay" > 
                <TextView
                    android:id="@+id/text_toolbar_title"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="left|center_vertical"
                    android:layout_marginLeft="5dp"
                    android:text="@string/app_name"
                    android:textColor="@android:color/white"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textStyle="bold" />
    
    </android.support.v7.widget.Toolbar> 
    
    0 讨论(0)
  • 2021-02-07 09:59

    add app:titleMarginStart="12dp" and it works like charm

     <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    app:layout_scrollFlags="scroll|enterAlways"
                    app:logo="@drawable/ic_arrow_back_white_24dp"
                    app:title="@string/app_name"
                    app:titleMarginStart="12dp" />
    
    0 讨论(0)
提交回复
热议问题