Как мне сделать заголовок в макете Android - PullRequest
0 голосов
/ 22 декабря 2011

Заголовок, который я ищу, будет выглядеть примерно так: enter image description here

Просто нужно что-то, чтобы оставаться слева, оставаться в центре и оставаться справа. Все, что я пробовал, немного переместило центр вправо, так что оно выглядит не в центре. Есть идеи или предложения?

EDIT: Кажется, это самое близкое, что я смог сделать с простым количеством кода

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#000"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/LinearLayout2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#000"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:layout_weight="1"
            android:text="First"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#fff" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_weight="1"
            android:text="Second"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#fff" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:layout_weight="1"
            android:text="3"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#fff" />
    </LinearLayout>

</LinearLayout>

Заранее спасибо

1 Ответ

0 голосов
/ 22 декабря 2011

Я скажу вам, как это сделать.Установите горизонтальный LinearLayout с layout_width of fill_parent и layout_height из wrap_content и weightSum, в вашем случае, 3. Заполните его тремя TextViews с layout_width, установленным в fill_parent, layout_height, установленным в wrap_content и layout_weight, установленным в 1. Затем первый гравитационный текст TextView в«налево», второй - «по центру», третий - «направо».Готово.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...