我想將我的LinearLayout放置在ScrollView中。當LinearLayout的高度很小時,它居中居中(見圖#1),但是當LinearLayout的高度大於屏幕的高度時,它表現得很奇怪。我無法看到LinearLayout的頂部(請參閱圖像#2),並且在ScrollView的底部有巨大的填充。我不知道這裏發生了什麼。當LinearLayout中有大量內容時,整個屏幕應該如圖3所示。滾動視圖中的中心內容
這是我的佈局文件:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#cccfff" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="28dp"
android:background="#ffffff"
android:orientation="vertical"
android:paddingBottom="40dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="40dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/tip_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:text="Title"
android:textColor="@color/orange_text"
android:textSize="@dimen/font_size_medium" />
<TextView
android:id="@+id/tip_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Description description..."
android:textSize="@dimen/font_size_small" />
</LinearLayout>
</ScrollView>
集'layout_gravity = center'用於爲*的意見集中* –
先生,你應該爲「按節奏,推節奏,推節奏,推節奏」的給予好評 –