ScrollView 仍然落后于它的区域
ScrollView Still comes Behind out of it's Area
这是我的Xml。
.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.xxx.xxx.MyActivity" >
<LinearLayout
android:id="@+id/viewFromDateToDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="horizontal" >
<EditText
android:id="@+id/txtFromDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="@drawable/timesheet_icon"
android:editable="false"
android:focusableInTouchMode="false"
android:hint="@string/txtFromDate"
android:inputType="date"
android:onClick="selectDate"
android:textSize="@dimen/generalTextSize" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:text="@string/lblFromTo"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="@dimen/generalTextSize" />
<EditText
android:id="@+id/txtToDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="@drawable/timesheet_icon"
android:editable="false"
android:focusableInTouchMode="false"
android:hint="@string/txtToDate"
android:inputType="date"
android:onClick="selectDate"
android:textSize="@dimen/generalTextSize" />
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:background="@drawable/green_button_department"
android:text="@string/btnShowData"
android:textColor="@color/white" />
</LinearLayout>
<View
android:id="@+id/upperSeparator"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="@id/viewFromDateToDate"
android:layout_marginTop="15dp"
android:background="@android:color/darker_gray" />
<LinearLayout
android:id="@+id/viewTimeOffDetailsHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/upperSeparator"
android:orientation="horizontal"
android:padding="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="@string/txtHeaderTimeOff"
android:textSize="@dimen/generalTextSize" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="@string/txtHeaderDate"
android:textSize="@dimen/generalTextSize" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/txtHeaderHours"
android:textSize="@dimen/generalTextSize" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/txtHeaderAction"
android:textSize="@dimen/generalTextSize" />
</LinearLayout>
<View
android:id="@+id/lowerSeparator"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="@id/viewTimeOffDetailsHeader"
android:background="@android:color/darker_gray" />
<ScrollView
android:id="@+id/scrollDiv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/lowerSeparator" >
<LinearLayout
android:id="@+id/viewTimeOffDetailsArea"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/viewTimeOffDetailsFooter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="15dp"
android:background="@drawable/green_button_department"
android:text="@string/btnSubmitTimeOff"
android:textColor="@color/white"
android:textSize="20sp" />
</LinearLayout>
</RelativeLayout>
我希望我的 LinerLayout scrollDiv
介于 lowerSeparator
和 viewTimeOffDetailsFooter
之间,但问题是 ScrolView 在 viewTimeOffDetailsFooter
启动后仍在显示它的元素。
.
这是一个输出。
Of XML Layout
在这里您可以看到 scrollDiv
的按钮仍然显示在 viewTimeOffDetailsFooter
按钮之后。我知道我不应该放整个文件但是我没有得到正确的解决方案,这就是原因。
谢谢。
您的 viewTimeOffDetailsFooter
没有任何位置 link 与 scrollDiv
,因此添加新规则 android:layout_below="@id/scrollDiv"
。它只能在没有 android:layout_alignParentBottom="true"
规则的情况下工作 - 需要尝试。
您只需将它放在 viewTimeOffDetailsFooter 上方,将以下属性添加到您的 scrollDiv
android:layout_above="@+id/viewTimeOffDetailsFooter"
这是我的Xml。 .
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.xxx.xxx.MyActivity" >
<LinearLayout
android:id="@+id/viewFromDateToDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="horizontal" >
<EditText
android:id="@+id/txtFromDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="@drawable/timesheet_icon"
android:editable="false"
android:focusableInTouchMode="false"
android:hint="@string/txtFromDate"
android:inputType="date"
android:onClick="selectDate"
android:textSize="@dimen/generalTextSize" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:text="@string/lblFromTo"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="@dimen/generalTextSize" />
<EditText
android:id="@+id/txtToDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="@drawable/timesheet_icon"
android:editable="false"
android:focusableInTouchMode="false"
android:hint="@string/txtToDate"
android:inputType="date"
android:onClick="selectDate"
android:textSize="@dimen/generalTextSize" />
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:background="@drawable/green_button_department"
android:text="@string/btnShowData"
android:textColor="@color/white" />
</LinearLayout>
<View
android:id="@+id/upperSeparator"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="@id/viewFromDateToDate"
android:layout_marginTop="15dp"
android:background="@android:color/darker_gray" />
<LinearLayout
android:id="@+id/viewTimeOffDetailsHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/upperSeparator"
android:orientation="horizontal"
android:padding="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="@string/txtHeaderTimeOff"
android:textSize="@dimen/generalTextSize" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="@string/txtHeaderDate"
android:textSize="@dimen/generalTextSize" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/txtHeaderHours"
android:textSize="@dimen/generalTextSize" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/txtHeaderAction"
android:textSize="@dimen/generalTextSize" />
</LinearLayout>
<View
android:id="@+id/lowerSeparator"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="@id/viewTimeOffDetailsHeader"
android:background="@android:color/darker_gray" />
<ScrollView
android:id="@+id/scrollDiv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/lowerSeparator" >
<LinearLayout
android:id="@+id/viewTimeOffDetailsArea"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/viewTimeOffDetailsFooter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="15dp"
android:background="@drawable/green_button_department"
android:text="@string/btnSubmitTimeOff"
android:textColor="@color/white"
android:textSize="20sp" />
</LinearLayout>
</RelativeLayout>
我希望我的 LinerLayout scrollDiv
介于 lowerSeparator
和 viewTimeOffDetailsFooter
之间,但问题是 ScrolView 在 viewTimeOffDetailsFooter
启动后仍在显示它的元素。
.
这是一个输出。
Of XML Layout
在这里您可以看到 scrollDiv
的按钮仍然显示在 viewTimeOffDetailsFooter
按钮之后。我知道我不应该放整个文件但是我没有得到正确的解决方案,这就是原因。
谢谢。
您的 viewTimeOffDetailsFooter
没有任何位置 link 与 scrollDiv
,因此添加新规则 android:layout_below="@id/scrollDiv"
。它只能在没有 android:layout_alignParentBottom="true"
规则的情况下工作 - 需要尝试。
您只需将它放在 viewTimeOffDetailsFooter 上方,将以下属性添加到您的 scrollDiv
android:layout_above="@+id/viewTimeOffDetailsFooter"