RelativeLayout 消失
RelativeLayout disappears
我的示例布局!
在纵向模式下,还可以,但是当我转身时,
滚动工作正常,根本没有按钮!按钮消失了!怎么了?求助!
我的示例布局!
在纵向模式下,还可以,但是当我转身时,
滚动工作正常,根本没有按钮!按钮消失了!怎么了?求助!
My example layout!
人像模式还可以,但是我转身的时候,
滚动工作正常,根本没有按钮!按钮消失了!怎么了?求助!
我的示例布局!
在纵向模式下,还可以,但是当我转身时,
滚动工作正常,根本没有按钮!按钮消失了!怎么了?求助!
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/mainScroller">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="@dimen/leftPadding"
android:paddingRight="@dimen/textMargin"
android:id="@+id/calendarLinear"
android:background="@drawable/linear_click"
android:clickable="true">
<ImageView
android:layout_width="@dimen/iconsSize"
android:layout_height="@dimen/iconsSize"
android:id="@+id/imageView2"
android:src="@drawable/calendar"
android:contentDescription="@string/iconCalendar" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/vylet"
android:id="@+id/tvDepart"
android:gravity="center_vertical"
android:layout_marginLeft="@dimen/leftPadding"
android:layout_weight="1"
style="@style/mainTextStyle" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="@dimen/lineHeight"
android:id="@+id/imageView4"
android:src="@drawable/separate_line" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/prilet"
android:id="@+id/tvArrive"
android:gravity="center_vertical|center_horizontal"
android:layout_weight="1"
style="@style/mainTextStyle"
android:background="@drawable/linear_click"
android:clickable="true" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/horLineHeight"
android:background="@color/vColor"
android:layout_weight="2"
android:layout_gravity="center">
</View>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:paddingRight="@dimen/textMargin"
android:paddingLeft="@dimen/textMargin"
android:paddingBottom="@dimen/textMargin"
android:gravity="bottom"
android:id="@+id/footerRelative">
<Button
android:layout_width="match_parent"
android:layout_height="55dp"
android:id="@+id/btnSearch"
android:layout_alignParentBottom="true"
style="@style/btnStyle"
android:gravity="center" />
</RelativeLayout>
我猜你能够看到完整的纵向布局只是因为纵向布局有更多 space 并且你的完整布局很合适,但横向有更少 space.
由于横向 space 比纵向少,您只能查看顶部滚动视图,因此只有该部分可以滚动!
如何解决?
将您的布局保持在按钮布局之上,这样您的按钮将始终在底部可见!
android:layout_above="@+id/footerRelative"
尝试将您的相对布局移动到 ScrollView 的顶部
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingRight="@dimen/textMargin"
android:paddingLeft="@dimen/textMargin"
android:paddingBottom="@dimen/textMargin"
android:id="@+id/footerRelative">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/mainScroller">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="@dimen/leftPadding"
android:paddingRight="@dimen/textMargin"
android:id="@+id/calendarLinear"
android:background="@drawable/linear_click"
android:clickable="true">
<ImageView
android:layout_width="@dimen/iconsSize"
android:layout_height="@dimen/iconsSize"
android:id="@+id/imageView2"
android:src="@drawable/calendar"
android:contentDescription="@string/iconCalendar" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/vylet"
android:id="@+id/tvDepart"
android:gravity="center_vertical"
android:layout_marginLeft="@dimen/leftPadding"
android:layout_weight="1"
style="@style/mainTextStyle" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="@dimen/lineHeight"
android:id="@+id/imageView4"
android:src="@drawable/separate_line" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/prilet"
android:id="@+id/tvArrive"
android:gravity="center_vertical|center_horizontal"
android:layout_weight="1"
style="@style/mainTextStyle"
android:background="@drawable/linear_click"
android:clickable="true" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/horLineHeight"
android:background="@color/vColor"
android:layout_weight="2"
android:layout_gravity="center">
</View>
</LinearLayout>
</ScrollView>
<Button
android:layout_width="match_parent"
android:layout_height="55dp"
android:id="@+id/btnSearch"
android:layout_alignParentBottom="true"
style="@style/btnStyle"
android:gravity="center" />
</RelativeLayout>
现在将显示您的完整布局!您的按钮将始终位于底部。
我的示例布局! 在纵向模式下,还可以,但是当我转身时, 滚动工作正常,根本没有按钮!按钮消失了!怎么了?求助! 我的示例布局! 在纵向模式下,还可以,但是当我转身时, 滚动工作正常,根本没有按钮!按钮消失了!怎么了?求助!
My example layout!
人像模式还可以,但是我转身的时候, 滚动工作正常,根本没有按钮!按钮消失了!怎么了?求助! 我的示例布局! 在纵向模式下,还可以,但是当我转身时, 滚动工作正常,根本没有按钮!按钮消失了!怎么了?求助!
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/mainScroller">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="@dimen/leftPadding"
android:paddingRight="@dimen/textMargin"
android:id="@+id/calendarLinear"
android:background="@drawable/linear_click"
android:clickable="true">
<ImageView
android:layout_width="@dimen/iconsSize"
android:layout_height="@dimen/iconsSize"
android:id="@+id/imageView2"
android:src="@drawable/calendar"
android:contentDescription="@string/iconCalendar" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/vylet"
android:id="@+id/tvDepart"
android:gravity="center_vertical"
android:layout_marginLeft="@dimen/leftPadding"
android:layout_weight="1"
style="@style/mainTextStyle" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="@dimen/lineHeight"
android:id="@+id/imageView4"
android:src="@drawable/separate_line" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/prilet"
android:id="@+id/tvArrive"
android:gravity="center_vertical|center_horizontal"
android:layout_weight="1"
style="@style/mainTextStyle"
android:background="@drawable/linear_click"
android:clickable="true" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/horLineHeight"
android:background="@color/vColor"
android:layout_weight="2"
android:layout_gravity="center">
</View>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:paddingRight="@dimen/textMargin"
android:paddingLeft="@dimen/textMargin"
android:paddingBottom="@dimen/textMargin"
android:gravity="bottom"
android:id="@+id/footerRelative">
<Button
android:layout_width="match_parent"
android:layout_height="55dp"
android:id="@+id/btnSearch"
android:layout_alignParentBottom="true"
style="@style/btnStyle"
android:gravity="center" />
</RelativeLayout>
我猜你能够看到完整的纵向布局只是因为纵向布局有更多 space 并且你的完整布局很合适,但横向有更少 space.
由于横向 space 比纵向少,您只能查看顶部滚动视图,因此只有该部分可以滚动!
如何解决?
将您的布局保持在按钮布局之上,这样您的按钮将始终在底部可见!
android:layout_above="@+id/footerRelative"
尝试将您的相对布局移动到 ScrollView 的顶部
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingRight="@dimen/textMargin"
android:paddingLeft="@dimen/textMargin"
android:paddingBottom="@dimen/textMargin"
android:id="@+id/footerRelative">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/mainScroller">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="@dimen/leftPadding"
android:paddingRight="@dimen/textMargin"
android:id="@+id/calendarLinear"
android:background="@drawable/linear_click"
android:clickable="true">
<ImageView
android:layout_width="@dimen/iconsSize"
android:layout_height="@dimen/iconsSize"
android:id="@+id/imageView2"
android:src="@drawable/calendar"
android:contentDescription="@string/iconCalendar" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/vylet"
android:id="@+id/tvDepart"
android:gravity="center_vertical"
android:layout_marginLeft="@dimen/leftPadding"
android:layout_weight="1"
style="@style/mainTextStyle" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="@dimen/lineHeight"
android:id="@+id/imageView4"
android:src="@drawable/separate_line" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/prilet"
android:id="@+id/tvArrive"
android:gravity="center_vertical|center_horizontal"
android:layout_weight="1"
style="@style/mainTextStyle"
android:background="@drawable/linear_click"
android:clickable="true" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/horLineHeight"
android:background="@color/vColor"
android:layout_weight="2"
android:layout_gravity="center">
</View>
</LinearLayout>
</ScrollView>
<Button
android:layout_width="match_parent"
android:layout_height="55dp"
android:id="@+id/btnSearch"
android:layout_alignParentBottom="true"
style="@style/btnStyle"
android:gravity="center" />
</RelativeLayout>
现在将显示您的完整布局!您的按钮将始终位于底部。