application name center alignment in android`

后端 未结 5 1147
花落未央
花落未央 2020-12-11 18:14

Can i center align the application name in android

by default the application name is aligned in the left side.

so how to make it aligned it center

相关标签:
5条回答
  • 2020-12-11 18:57

    you have to change the theme in manifests its actually explained well in android developer website ... review this link https://developer.android.com/training/appbar/setting-up#java

    0 讨论(0)
  • 2020-12-11 19:15

    you will try this in xml

    android:layout_centerhorizontal="true"
    
    0 讨论(0)
  • 2020-12-11 19:16

    you will have to create a custom theme and set the style of window title to suit your needs.
    This has some guideline http://labs.makemachine.net/2010/03/custom-android-window-title/

    You could also use FEATURE_CUSTOM_TITLE and set format accordingly. This approach is detailed here.
    How to change the text on the action bar

    0 讨论(0)
  • 2020-12-11 19:18

    To use a custom title in your Toolbar all you need to do is remember is that Toolbar is just a fancy ViewGroup so you can add a custom title like so:

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar_top"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:minHeight="?attr/actionBarSize"
        android:background="@color/action_bar_bkgnd"
        app:theme="@style/ToolBarTheme" >
    
    
         <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Toolbar Title"
            android:layout_gravity="center"
            android:id="@+id/toolbar_title" />
    
    
        </android.support.v7.widget.Toolbar>

    This means that you can style the TextView however you would like because it's just a regular TextView. So in your activity you can access the title like so:

    Toolbar toolbarTop = (Toolbar) findViewById(R.id.toolbar_top);
    TextView mTitle = (TextView) toolbarTop.findViewById(R.id.toolbar_title);
    
    0 讨论(0)
  • 2020-12-11 19:20

    please set your layout and textview gravity to center if it is not working then try textview layoutGravity to center

    0 讨论(0)
提交回复
热议问题