3

私は、Android アプリのタイトルで 2 つの配置を実現することに苦労しています。私の要件によると、タイトルには、左揃えの「名前」と右揃えの「バージョン番号」が必要です。

これまでのところ、AndroidManifest.xml ファイルの application タグの label 属性が html を受け入れるかどうかをテストすることを試みましたが、そうではないようです :(。また、他の同様の質問のいくつかから、タイトルのスタイルは、カスタム テーマを使用して変更できます.しかし、これは私の質問に答えません:

「アプリケーション名の部分に対して、2 つの異なる配置 (たとえば、左と右)、またはその場合は 2 つの異なるテーマを使用できますか?」

PS: 希望するアプリケーション タイトルのスクリーンショットを以下に添付します。

ここに画像の説明を入力

4

1 に答える 1

2

カスタムタイトルバーを作成できます..ここにサンプルコードがあります。

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.i_main);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.i_title);

    final TextView titleLeft = (TextView) findViewById(R.id.title_left);

    final TextView titleRight = (TextView) findViewById(R.id.title_right);
    titleLeft.setText("Checker");
    titleRight.setText("Version 5.44");

}

i_title.xml

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/title_left"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="app name" />

    <TextView
        android:id="@+id/title_right"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:text="app version" />

</RelativeLayout>
于 2012-11-05T08:59:29.323 に答える