简体   繁体   English

如何在Android中居中对齐标题文本?

[英]How can I center align my header text in Android?

  <application
      android:name="com.example.ma01_gt_gpro_1.GlobalClass"
    android:allowBackup="true"
    android:icon="@drawable/gproicon"
    android:label="@string/app_name"
    android:theme="@style/CustomActionBarTheme" >
    <activity
        android:name="com.example.ma01_gt_gpro_1.MG00LoginForm"  
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name="MG03Navigation" android:noHistory="true"></activity>
    <activity android:name="MG02DataSynchronize" android:noHistory="true"></activity>
    <activity android:name="MG02DataSynchronize1" ></activity>
    <activity android:name="MG01MainForm" android:noHistory="true"></activity>
    <activity android:name="MT01ASalesOrderView" android:noHistory="true"></activity>

    <activity android:name="MT01_B_ListParty" android:noHistory="true"></activity>
    <activity android:name="MT01_C_ListItems" ></activity>
    <activity android:name="MT02_A_ListParty" android:noHistory="true"></activity>
    <activity android:name="MT02_B_ListPaymentMode" ></activity>
     <activity android:name="MT01SalesOrder" android:label="                            SALES ORDER"></activity>
    <activity android:name="MT02CollectionEntry" android:label="                            COLLECTION"></activity>
    <activity android:name="MT02_C_CollectionReport" android:label="                            COLLECTION REPORT"></activity>
    <activity android:name="MR01SalesOrderReport" android:label="                           SALESORDER REPORT" ></activity>

</application>

Here I found an temporary solution android:label="SALESORDER REPORT" > 在这里,我找到了一个临时解决方案android:label="SALESORDER REPORT" >

But it won't get work with large screens 但无法在大屏幕上使用

Step 1: Remove ActionBar. 步骤1:删除ActionBar。

Step 2: Take some TextView with align parent_top. 步骤2:取得一些TextView并对齐parent_top。

Step 3: And place your Activity name on that textview programmatically. 步骤3:然后将“活动”名称以编程方式放在该textview上。

hope this will help you 希望这个能对您有所帮助

Thanks to all who supported me ? 感谢所有支持我的人?

i Found an solution: 我找到了解决方案:

How to center align the ActionBar title in Android? 如何在Android中居中对齐ActionBar标题?

getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); 。getSupportActionBar()setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); getSupportActionBar().setCustomView(R.layout.abs_layout); getSupportActionBar()setCustomView(R.layout.abs_layout)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM