我有一个问题,我在滚动视图中显示片段,但事实是scrillview总是显示额外的空间(或者我认为完整的片段页面),而数据只有半页。如何让scrollview不显示整个片段页面而只显示文本部分。虽然我将父LinareLayout包装在片段活动中,但对我不起作用。
活动xml在滚动视图中放置一个LinearLayout,然后我用一个片段替换它
<?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="match_parent"
android:background="#ffffffff"
android:orientation="vertical"
android:weightSum="10">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_weight="1.1"
android:background="#FF52caf7"
android:orientation="horizontal"
android:weightSum="1">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="15dp"
android:clickable="true"
android:onClick="backtoschedule"
android:src="@drawable/back" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.6">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal"
android:text="Schedule Order"
android:textColor="#FFFFFFFF"
android:textSize="@dimen/txtm" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_weight="7.9"
android:background="@drawable/pbackground"
android:orientation="vertical"
android:weightSum="10.05">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="5.975"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/defaultsofragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.025"
android:background="#ffd1d1d1" />
///////////////////////////////////////////////////////////////////////////
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:orientation="horizontal"
android:weightSum="10">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="6"
android:orientation="vertical"
android:weightSum="10">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6"
android:gravity="left"
android:paddingLeft="10dp"
android:text="Instruction"
android:textColor="#ff000000"
android:textSize="@dimen/txtss" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:gravity="left"
android:paddingLeft="10dp"
android:text="You agree with terms and conditions"
android:textColor="#ff000000"
android:textSize="@dimen/txts2" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:orientation="vertical"
android:weightSum="10">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:gravity="center|left"
android:text="Use Coupon"
android:textColor="#ff000000"
android:textSize="@dimen/txtss" />
<EditText
android:id="@+id/couponcode"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="20dp"
android:layout_marginRight="20dp"
android:layout_weight="6"
android:background="@drawable/edittextstyle"
android:gravity="center"
android:hint="coupon code"
android:textColor="#ff000000"
android:textColorHint="#FFABABAB"
android:textCursorDrawable="@null"
android:textSize="@dimen/txtss" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.025"
android:background="#ffd1d1d1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:background="@drawable/img"></LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:orientation="vertical">
<Button
android:id="@+id/button"
style="@android:style/TextAppearance.Large"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:background="#ff57caf2"
android:onClick="orderconfirm"
android:text="Confirm Order"
android:textColor="#fff0f0f0"
android:textSize="@dimen/txtss" />
</LinearLayout>
</LinearLayout>
////////////////////////////////////////
The fragment activity 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="wrap_content"
android:background="@drawable/pbackground"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*">
<TableRow
android:layout_weight="1"
android:gravity="left">
<TextView
android:layout_column="1"
android:padding="3dip"
android:text="ORDER DETAILS"
android:textAllCaps="true"
android:textColor="#000"
android:textSize="@dimen/txtss" />
</TableRow>
<TableRow
android:layout_weight="1"
android:gravity="left"
android:weightSum="1">
<TextView
android:layout_width="0dp"
android:layout_column="1"
android:layout_weight="0.5"
android:padding="3dip"
android:text="Delivery Type"
android:textColor="#ff000000"
android:textSize="@dimen/txts"
android:textStyle="bold" />
<TextView
android:id="@+id/dtype"
android:layout_width="0dp"
android:layout_column="1"
android:layout_weight="0.5"
android:padding="3dip"
android:text="Loading..."
android:textColor="#ff000000"
android:textSize="@dimen/txts" />
</TableRow>
<TableRow
android:layout_weight="1"
android:gravity="left"
android:weightSum="1">
<TextView
android:layout_width="0dp"
android:layout_column="1"
android:layout_weight="0.5"
android:padding="3dip"
android:text="Schedule Pickup"
android:textColor="#ff000000"
android:textSize="@dimen/txts"
android:textStyle="bold" />
</TableRow>
<TableRow
android:layout_weight="1"
android:gravity="left"
android:weightSum="1">
<TextView
android:layout_width="0dp"
android:layout_column="1"
android:layout_weight="0.5"
android:padding="3dip"
android:text="Date"
android:textColor="#FF000000"
android:textSize="@dimen/txts" />
<TextView
android:id="@+id/spdate"
android:layout_width="0dp"
android:layout_column="1"
android:layout_weight="0.5"
android:padding="3dip"
android:text="Loading..."
android:textColor="#FF000000"
android:textSize="@dimen/txts" />
</TableRow>
<TableRow
android:layout_weight="1"
android:gravity="left"
android:weightSum="1">
<TextView
android:layout_width="0dp"
android:layout_column="1"
android:layout_weight="0.5"
android:padding="3dip"
android:text="Time"
android:textColor="#FF000000"
android:textSize="@dimen/txts" />
<TextView
android:id="@+id/sptime"
android:layout_width="0dp"
android:layout_column="1"
android:layout_weight="0.5"
android:padding="3dip"
android:text="Loading..."
android:textColor="#FF000000"
android:textSize="@dimen/txts" />
</TableRow>
<TableRow
android:layout_weight="1"
android:gravity="left"
android:weightSum="1">
<TextView
android:layout_width="0dp"
android:layout_column="1"
android:layout_weight="0.5"
android:padding="3dip"
android:text="Schedule DropOff"
android:textColor="#ff000000"
android:textSize="@dimen/txts"
android:textStyle="bold" />
</TableRow>
<TableRow
android:layout_weight="1"
android:gravity="left"
android:weightSum="1">
<TextView
android:layout_width="0dp"
android:layout_column="1"
android:layout_weight="0.5"
android:padding="3dip"
android:text="Date"
android:textColor="#FF000000"
android:textSize="@dimen/txts" />
<TextView
android:id="@+id/sddate"
android:layout_width="0dp"
android:layout_column="1"
android:layout_weight="0.5"
android:padding="3dip"
android:text="Loading..."
android:textColor="#FF000000"
android:textSize="@dimen/txts" />
</TableRow>
<TableRow
android:layout_weight="1"
android:gravity="left"
android:weightSum="1">
<TextView
android:layout_width="0dp"
android:layout_column="1"
android:layout_weight="0.5"
android:padding="3dip"
android:text="Time"
android:textColor="#FF000000"
android:textSize="@dimen/txts" />
<TextView
android:id="@+id/sdtime"
android:layout_width="0dp"
android:layout_column="1"
android:layout_weight="0.5"
android:padding="3dip"
android:text="Loading..."
android:textColor="#FF000000"
android:textSize="@dimen/txts" />
</TableRow>
<View
android:layout_height="1dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:layout_weight="1"
android:gravity="center" />
<TableRow
android:layout_weight="1"
android:gravity="left">
<TextView
android:layout_column="1"
android:padding="3dip"
android:text="Address"
android:textAllCaps="true"
android:textColor="#000"
android:textSize="@dimen/txtss" />
</TableRow>
<TableRow
android:layout_weight="1"
android:gravity="left">
<TextView
android:id="@+id/caddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:inputType="textMultiLine"
android:padding="3dip"
android:scrollbars="vertical"
android:text="Shanti Niketanjnkwejrkjwoperjposdasdasdasdasdasdasdwejprjwpoe,Lucknow,22-44-33"
android:textColor="#000"
android:textSize="@dimen/txts" />
</TableRow>
</TableLayout>
</LinearLayout>
答案 0 :(得分:1)
在Scrollview中使用此属性..
android:fillViewport="true"