如何在Android中修复“subLayout”

时间:2016-06-28 18:11:42

标签: android android-layout

我正在创建一个获取某些值的应用,您点击一个按钮并返回其他一些值,这些视图分布在2个更大的垂直LinearLayout的子地图中,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp">

    <RelativeLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center_horizontal"
        android:layout_weight="0.4">
        <EditText
            android:layout_width="70dp"
            android:layout_height="wrap_content"
            android:inputType="number"
            android:id="@+id/number1" />
        <EditText
            android:layout_width="70dp"
            android:layout_height="wrap_content"
            android:inputType="number"
            android:id="@+id/number2"
            android:layout_below="@+id/number1" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Calc!"
            android:id="@+id/calcButton"
            android:layout_below="@+id/number2"/>
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center_horizontal"
        android:layout_weight="0.6"
        android:layout_alignParentBottom="true">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Answer"
            android:id="@+id/Answer" />
    </RelativeLayout>
</LinearLayout>

我的问题是,当我点击我的EditText并且键盘出现时,答案的TextView会上升到键盘并“覆盖”我的按钮(整个RelativeLayout跟随键盘),有一种方法可以将RelativeLayout设置为固定,以使其保持在意味着什么位置? 这里发生了什么:

enter image description here 有一种方法可以修复RelativeLayout吗?

1 个答案:

答案 0 :(得分:0)

尝试为Android Manifest文件中的活动设置android:windowSoftInputMode =“adjustPan”。