2

Androidのレイアウトについて質問があります。ビューの中央にテキストを配置するディスプレイがあり、上部にヘッダーがあり、下部に3つのボタンがあります。私が問題を抱えているのは、TextView(ScrollView内にあります)を拡大して、使用可能な画面スペースを埋めることです。ScrollViewのlayout_heightを"fill_parent"に設定すると、3つのボタンが画面の下部から押し出されます。「wrap_content」に設定すると、TextViewに配置されるテキストをサポートするために必要なだけの大きさになります。

これが私が使用しているレイアウトのXMLです:

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

<LinearLayout android:orientation="horizontal"
    android:gravity="top"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >
    <ImageView android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher">
    </ImageView>
    <TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        style="@android:style/TextAppearance.Large"
        android:text="@string/meetingdetail" />
</LinearLayout>

<ScrollView
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent">
    <TextView android:id="@+id/meeting"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        style="@android:style/TextAppearance.Medium" />
</ScrollView>

<Button android:id="@+id/navigation"
    android:text="@string/naviation"
    android:onClick="meetingInfoOnClick"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />

<Button android:id="@+id/mapsingle"
    android:text="@string/mapsingle"
    android:onClick="meetingInfoOnClick"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />

<Button android:id="@+id/goback"
    android:text="@string/goback"
    android:onClick="meetingInfoOnClick"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />

</LinearLayout>

誰かが、TextViewを使用してScrollViewを使用可能なスペースでいっぱいにし、それでも3つのボタンを表示できるようにするために最適な方法を提案できますか?

4

2 に答える 2

2

ScrollViewの高さを0dpに設定しその重みを1に設定します。

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1" >

<TextView android:id="@+id/meeting"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    style="@android:style/TextAppearance.Medium" />
</ScrollView>

ただし、複数のビューをスクロール可能にする予定がない場合は、ScrollViewを削除して次を使用する必要があります。

   android:scrollbars="vertical"

TextView自体はスクロール可能であるため、TextViewの属性。

于 2013-01-04T21:18:25.687 に答える
0

ScrollViewタグコードをに置き換えるだけです。

<ScrollView
android:layout_width="fill_parent" 
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView android:id="@+id/meeting"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    style="@android:style/TextAppearance.Medium" />
</ScrollView>

それでも問題が解決しない場合は、問題なく動作します。教えてください。動作する場合は、回答として受け入れます。

于 2013-01-04T21:19:57.373 に答える