Расширение TextView без покрытия других представлений - PullRequest
2 голосов
/ 31 марта 2012

Я пытаюсь реализовать макет в Android, который состоит из нескольких TextView с и некоторых кнопок. Я хочу, чтобы один из TextView (который представляет собой журнал игры, которую я реализую) занимал все доступное пространство и имел возможность прокрутки, если текста слишком много для отображения. Тем не менее, мне кажется, что при развертывании я не могу получить его без наложений под ним - вместо этого он останавливается внизу экрана:

enter image description here

На этом скриншоте есть TextView «табло», TextView «рука», TextView «журнал» и LinearLayout с несколькими кнопками. Все TextView имеют динамическую длину, но первые два не должны занимать более нескольких строк. Проблема в том, что журнал расширяется и закрывает кнопку под ним (на плюсе он прокручивается). Можете ли вы показать мне, как это исправить?

Вот макет XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <TextView
        android:id="@+id/scoreboard"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:text="Scoreboard" />

    <TextView
        android:id="@+id/handinfo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/scoreboard"
        android:text="Hand" />

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" >

        <Button
            android:id="@+id/stay"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:enabled="false"
            android:text="Stay" />

        <Button
            android:id="@+id/leave"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:enabled="false"
            android:text="Leave" />

        <Button
            android:id="@+id/pay"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:enabled="false"
            android:text="Pay" />

        <Button
            android:id="@+id/payWithWild"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:enabled="false"
            android:text="Pay Wild" />

        <Button
            android:id="@+id/dontPay"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:enabled="false"
            android:text="Don&apos;t Pay" />
    </LinearLayout>

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/handinfo" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/log"
            android:text="" />

    </ScrollView>



</RelativeLayout>

1 Ответ

4 голосов
/ 31 марта 2012

Добавьте следующие атрибуты к вашему ScrollView, и это должно исправить отображение:

android:layout_below="@id/handinfo"
android:layout_above="@id/linearLayout1"
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...