设置ScrollView的属性
android:fillViewport="true"
代码示例:
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <include layout="@layout/navtion" /> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="50dp" android:layout_marginTop="51dp" android:fillViewport="true"> <LinearLayout android:id="@+id/mainLin" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/gray_sky" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:background="@color/white" android:orientation="horizontal" android:padding="10dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="订 单 号: " android:textColor="@color/black" android:textSize="16sp" /> <TextView android:id="@+id/act_ts_orderIdTv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="20162154345" android:textColor="@color/black" android:textSize="16sp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="2dp" android:background="@color/white" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="10dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="货 主: " /> <TextView android:id="@+id/act_ts_hzNameTv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="张三" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" android:paddingBottom="10dp" android:paddingLeft="10dp" android:paddingRight="10dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="发货信息: " /> <TextView android:id="@+id/act_ts_fhxxTv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:maxLines="2" android:minLines="2" android:text="测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试" /> </LinearLayout> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="2dp" android:background="@color/white" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="10dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="车 主: " /> <TextView android:id="@+id/act_ts_czNameTv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="李四" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" android:paddingBottom="10dp" android:paddingLeft="10dp" android:paddingRight="10dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="运输信息: " /> <TextView android:id="@+id/act_ts_sjNameTv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:maxLines="1" android:text="潘佳佳" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" · " /> <TextView android:id="@+id/act_ts_carIdTv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="京A12345" /> </LinearLayout> </LinearLayout> <LinearLayout android:id="@+id/act_ts_tsTypeLin" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginTop="10dp" android:background="@color/white" android:gravity="center"> <TextView android:id="@+id/act_ts_tsTypeTv" android:layout_width="wrap_content" android:layout_height="50dp" android:gravity="center" android:padding="15dp" android:text="虚假信息" android:textColor="@color/black" android:textSize="18sp" /> <View android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="1" /> <ImageView android:layout_width="wrap_content" android:layout_height="match_parent" android:padding="15dp" android:src="@drawable/t_jiantou_right" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white" android:focusable="true" android:focusableInTouchMode="true" android:orientation="vertical" android:padding="10dp"> <EditText android:id="@+id/act_ts_edit" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="top|left" android:hint="请详细描述" android:maxLines="4" android:minLines="4" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal"> <com.m68hcc.widget.MyImageView android:id="@+id/act_ts_img1" android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="1" android:scaleType="centerInside" android:src="@drawable/t_addphoto" /> <com.m68hcc.widget.MyImageView android:id="@+id/act_ts_img2" android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="1" android:scaleType="centerInside" /> <com.m68hcc.widget.MyImageView android:id="@+id/act_ts_img3" android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="1" android:scaleType="centerInside" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" android:padding="10dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="上传凭证" android:textColor="@color/black" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="(最多可上传3张)" /> <View android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="1" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="重新选择" android:textColor="@color/blue" /> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@color/white" /> </LinearLayout> </ScrollView> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:background="#ff3d3e" android:gravity="center" android:onClick="onSubmit" android:padding="15dp" android:text="确认投诉" android:textColor="@color/white" android:textSize="20sp" /> </FrameLayout>
附上一张前辈给的方案图