Java 如何把标签放在中间?
我想把我的应用程序的标签放在中间。默认情况下,它与左侧对齐 标签是此处显示的单词CAIN 我该怎么做? 以下是AndroidManifest.xml的代码:Java 如何把标签放在中间?,java,android,xml,Java,Android,Xml,我想把我的应用程序的标签放在中间。默认情况下,它与左侧对齐 标签是此处显示的单词CAIN 我该怎么做? 以下是AndroidManifest.xml的代码: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.khurshidyakubov.cain"> <a
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.khurshidyakubov.cain">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
**android:label="@string/app_name"**
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
在你的主要活动中试试这个
ActionBar actionbar = getActionBar();
TextView textview = new TextView(getApplicationContext());
LayoutParams lps = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT);
textview.setLayoutParams(lps);
textview.setText("CAIN");
textview.setTextColor(Color.WHITE);
textview.setGravity(Gravity.CENTER);
textview.setTextSize(22);
actionbar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionbar.setCustomView(textview);
在textview上设置te标签的位置。这个文本视图给出了android:layou\u gravity=center