我已经阅读了很多帖子,似乎无法找到如何去做。如何避免在RelativeLayout上显示softkeyboard的元素重叠
我正在尝试创建以下布局xml。
在中间我想要一个带有一些按钮的LinearLayout,并且在LinearLayout的顶部和开始之间我想要一个textView。
的的LinearLayout是滚动型是内RelativeLayout的
我通过把的LinearLayout和TextView的一个RelativeLayout的内部实现这里面。 LinearLayout位于父级的中心,textView位于linearLayout之上并位于父级的顶部。文本垂直居中。
问题在于键盘开启时。我只在ScrollView中放置了LinearLayout。 如果我在清单中使用adjustPan,则没有任何反应,我无法滚动。如果我使用adjustResize,那么文本视图会出现在LinearLayout的顶部而不是上面。那我该怎么做呢?还是不可能? 我只想要linearLayout可以滚动,如果需要的话。 下面是代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/black_overlay"
android:animateLayoutChanges="true"
android:hapticFeedbackEnabled="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_centerInParent="true"
android:id="@+id/scrollView"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_horizontal"
android:id="@+id/mLayout"
>
<Button
android:layout_marginBottom="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Match"
android:id="@+id/btn_newMatch"
style="@style/ButtonBar"
android:typeface="monospace"/>
<Button
android:layout_marginBottom="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Manage Matches"
android:id="@+id/btn_manageMatches"
style="@style/ButtonBar"
android:typeface="monospace"/>
<Button
android:layout_marginBottom="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Manage Teams"
android:id="@+id/btn_manageTeams"
style="@style/ButtonBar"
android:typeface="monospace"/>
<Button
android:layout_marginBottom="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Settings"
android:id="@+id/btn_settings"
style="@style/ButtonBar"
android:typeface="monospace"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Logout"
android:id="@+id/btn_logout"
style="@style/ButtonBar"
android:typeface="monospace"/>
</LinearLayout>
</ScrollView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Name"
android:typeface="monospace"
android:layout_above="@id/scrollView"
android:layout_alignParentTop="true"
android:gravity="center"
android:textSize="50dp"
android:textAppearance="?android:textAppearanceMediumInverse"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"/>
</RelativeLayout>
这是怎么了目前与adjustResize样子:
没有键盘:http://i.stack.imgur.com/Y7WNo.jpg
随着键盘:http://i.stack.imgur.com/MlWpg.jpg
可有人点我在正确的方向?
Thx !!! :)
使用adjustPan屏幕不会调整大小。键盘停留在布局顶部,因此布局不会重叠,但也不会滚动。 – juancamilo87
可以请你详细说明你的问题..!你想要什么? – Andrain
我真正想要的是布局调整到一个最小高度,没有任何东西重叠,并成为可滚动。但读了很多后,我不认为这是可能的。所以我希望它可以滚动以避免我在图像上显示的重叠。 – juancamilo87