LinearLayout
内部に があるaScrollView
がありますがandroid:layout_height="fill_parent"
、 の高さいっぱいまで拡張しませんScrollView
。私のレイアウトは次のようになります。
level layout layout_width layout_height
1 LinearLayout fill_parent fill_parent
2 LinearLayout fill_parent wrap_content
3 (some irrelevant stuff)
2 ScrollView fill_parent fill_parent <-- this expands full height
3 LinearLayout fill_parent fill_parent <-- this does not (has orientation=vertical)
(following stuff probably are irrelevant, but just to be sure:)
4 TextView fill_parent fill_parent
4 LinearLayout fill_parent wrap_content
のEclipse でを選択すると([アウトライン] パネルで) がLinearLayout
の高さ全体に拡張されないことがわかります画面の下部まで拡大しません。どうすればそうすることができますか?ScrollView
Android Layout Editor
ScrollView
LinearLayout
私が達成しようとしている効果は、テキストとその下にボタンを配置することです (LinearLayout
レベル 4 の内部にはボタンしかありません)。テキストは、スクロールバーが必要なほど大きくなる可能性があります。その場合、ユーザーはボタンを表示するために下にスクロールする必要があります。テキストがスクロール バーに対して十分な大きさでない場合はLinearLayout
、ボタンを含むものを画面の下部に貼り付けます。
最初、私は完全な XML を投稿するべきではないと考えていました。なぜなら、通常、質問に膨大な量のコードが含まれているのを見るのはターンダウンになるからです。ただし、必要になる可能性があるため、完全なレイアウトを次に示します。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/video_layout"
android:focusable="true"
style="@style/VideoLayout">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:foreground="@android:drawable/ic_media_play"
android:foregroundGravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/video_thumb"
android:padding="5dip"
android:background="#454545"/>
</FrameLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="true"
style="@style/VideoTitle"
android:id="@+id/video_title"
android:layout_gravity="center"
android:layout_weight="1"/>
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<!-- this ScrollView expands the full height of the screen.
However, the next LinearLayout does not expand the full height of the ScrollView -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_gravity="fill"
android:orientation="vertical"
android:id="@+id/info_layout">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/info_body"
style="@style/InfoText"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
style="@android:style/ButtonBar">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:text="@string/button_readmore"
android:id="@+id/btn_read_more"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
現時点ではandroid:layout_gravity="bottom"
、問題のあるに頼ってLinearLayout
います。これにより、ボタンが画面の下部に固定されます。しかし、それはまた、テキストが画面の下部にくっつくようになります。これは、私が求めていたものとはまったく異なります.
更新:それをスクラッチするandroid:layout_gravity="bottom"
とScrollView
、スクロールできなくなります。他のアイデア?