我想将我的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'用于为*的意见集中* –
先生,你应该为“按节奏,推节奏,推节奏,推节奏”的给予好评 –