Android 无法用RelativeLayout完全填充屏幕,并且无法在键盘打开时调整大小
这是我的XML。我试图填满整个屏幕,当我在Eclipse中查看它时,它填满了整个屏幕。然而,当我在手机上打开它时,所有的东西都变小了,并且有重叠的视图。我不知道发生了什么事Android 无法用RelativeLayout完全填充屏幕,并且无法在键盘打开时调整大小,android,xml,android-relativelayout,Android,Xml,Android Relativelayout,这是我的XML。我试图填满整个屏幕,当我在Eclipse中查看它时,它填满了整个屏幕。然而,当我在手机上打开它时,所有的东西都变小了,并且有重叠的视图。我不知道发生了什么事 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" andro
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/front"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:text="Front"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/frontInput"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_below="@+id/front"
android:ems="10" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/frontInput"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:text="Back"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/backInput"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/back"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:ems="10"
android:inputType="textMultiLine" />
<TextView
android:id="@+id/background"
android:layout_width="wrap_content"
android:layout_marginLeft="5dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/backInput"
android:layout_marginTop="44dp"
android:text="Background"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="@+id/colors_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/backInput"
android:layout_marginLeft="30dp"
android:layout_marginTop="22dp"
android:layout_toRightOf="@+id/background"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/colors_spinner" >
<Button
android:id="@+id/save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save" />
<Button
android:id="@+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel" />
</LinearLayout>
</RelativeLayout>
这就是它在Eclipse中的外观
但我明白了:
另一件事是,当我打开键盘时,我的视图不会重新缩放,所以你可以看到所有东西,但更小的视图可以看到你正在键入的内容等等。。。我已经为特定的活动添加了
android:windowSoftInputMode=“adjustResize”
,但什么都没有发生。。。有什么想法吗?谢谢大家…如果您使用adjustResize,它将调整所有内容的大小,使其尽可能适合。另一个选项是adjustPan,它将滚动窗口,使聚焦的编辑文本在视图中,插入符号可见。除此之外,没有真正的方法来控制事情
在你的例子中,你有一些精确的高度在那里,所以它不能很好地与调整大小,因为你不能收缩一个精确的高度
另外,永远不要相信Eclipse中的事物是什么样子的。这是一种尝试,它试图展示出与Android实际操作方式没有代码共享的东西,这应该被视为一种估计。真正的布局可能最终看起来有很大的不同,特别是对于复杂的布局。那么我应该怎么做才能使它工作呢?这就是我感兴趣的。。。我想要第一张图片中的设计,同时可以选择在键盘打开时重新缩放…尝试将线性布局上方的微调器与按钮对齐,并将线性布局与屏幕底部对齐。我认为,这应该可以修复非键盘视图。使用键盘,看看这些更改看起来有多糟糕。真正的问题是它无法调整固定大小的EditText。尝试确保元素有一个位于下方和上方的布局,并设置其高度以填充父元素-这将使其在布局其余元素后占据剩余空间。我将尝试此操作并返回给您。