【发布时间】:2017-01-21 18:15:38
【问题描述】:
我的布局有问题。我正在尝试构建一个可在横向和纵向上运行的 xml 文件。在一个特定的布局上,在旋转(从纵向到横向)时,布局似乎会自行扩展。虽然,每一个对象都在那里,但我得到了很大的差距。
这是纵向的。
这些描述了旋转后的情况(横向)。
我的xml文件是:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
android:orientation="vertical">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:fitsSystemWindows="false"
android:id="@+id/coordintorLayout">
<com.andremion.floatingnavigationview.FloatingNavigationView
android:id="@+id/floating_navigation_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
app:layout_anchor="@+id/toolbar"
app:layout_anchorGravity="bottom|end"
app:drawMenuBelowFab="true"
app:headerLayout="@layout/navigation_view_header"
app:menu="@menu/menu" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryDark"
android:orientation="vertical">
<include
layout="@layout/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center"
android:gravity="bottom|center">
<!--
<include
layout="@layout/single_item_customize"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
-->
<ViewStub
android:id="@+id/layout_stub1"
android:inflatedId="@+id/inflated_layout_stub1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.75" />
<ViewStub
android:id="@+id/layout_stub2"
android:inflatedId="@+id/inflated_layout_stub2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.75" />
<ViewStub
android:id="@+id/layout_stub3"
android:inflatedId="@+id/inflated_layout_stub3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.25" />
<TextView
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.25"
android:inputType="textMultiLine"
android:ems="10"
android:id="@+id/editText"
android:background="@color/colorPrimaryDark"
android:clickable="false"
android:editable="false"
android:enabled="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:freezesText="false"
android:linksClickable="false"
android:longClickable="false"
android:text="@string/default_message" />
</LinearLayout >
</ScrollView>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
我很确定我的 xml 有问题,但我无法弄清楚。
提前致谢。
PS:我已经有了
android:configChanges="orientation|screenSize|keyboardHidden"
在我的清单中。
【问题讨论】:
-
嗨。请不要将您的解决方案编辑到问题的文本中。在 Stack Overflow 上,当一个问题有一个被接受的答案时,它就被认为已解决。请将您编辑的解决方案作为答案发布,并将其标记为已接受(可能有 24 小时的限制,您无法接受自己的答案,因此您必须再等待大约 10 个小时)。
-
对不起。我的错。改了。
标签: android xml android-layout screen-rotation