4

我正在使用 Sherlock 操作选项卡,因此有一个选项卡的片段活动。不幸的是,当键盘出现时,会发生以下情况:

在此处输入图像描述

键盘与第三个文本框正下方的两个按钮重叠。但是,我希望在打开键盘时可以看到这两个按钮。

我尝试了几件事:

  • 添加android:windowSoftInputMode="adjustResize"以及android:windowSoftInputMode="adjustPan"包含这三个选项卡的活动
  • 将图示的选项卡片段包装在滚动视图中,该视图部分工作,允许屏幕可滚动以查看两个按钮

这是片段的 XML:

<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

    <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#EBEBEB"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="20dp"
        android:layout_weight="1"
        android:gravity="right" >

        <EditText
            android:id="@+id/TextBox"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#ffffff"
            android:height="50dp"
            android:hint="@string/BoxHint"
            android:paddingLeft="15dp" >
        </EditText>

        <TextView
            android:id="@+id/LocBoxHint"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_below="@+id/TextBox"
            android:background="#ffffff"
            android:gravity="center"
            android:padding="10dp"
            android:text="\@"
            android:textSize="22dp" />

        <EditText
            android:id="@+id/LocBox"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:layout_below="@+id/TextBox"
            android:layout_toRightOf="@+id/LocBoxHint"
            android:background="#ffffff"
            android:hint="Joey&apos;s Pizza" >
        </EditText>

        <TextView
            android:id="@+id/DateTimeBoxHint"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_below="@+id/LocBoxHint"
            android:background="#ffffff"
            android:gravity="center"
            android:padding="10dp"
            android:text="#"
            android:textSize="22dp" />

        <EditText
            android:id="@+id/DateTimeBox"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:layout_below="@+id/LocBox"
            android:layout_toRightOf="@+id/DateTimeBoxHint"
            android:background="#ffffff"
            android:hint="Friday 8pm"
            android:paddingRight="60dp"
            android:layout_marginBottom="50dp" />

        <ImageButton
            android:id="@+id/DateTimePicker"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/LocBox"
            android:onClick="dateTimeButton"
            android:src="@drawable/ic_menu_today"
            android:background="#ffffff" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:layout_below="@+id/DateTimeBox"
            android:orientation="horizontal"
            android:layout_marginTop="-50dp" >

            <Button
                android:id="@+id/infoButton"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="5"
                android:onClick="infoButton"
                android:text="i"
                android:textColor="#ffffff" />

            <Button
                android:id="@+id/Button"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:layout_weight="2"
                android:onClick="planButton"
                android:text="@string/Button"
                android:textColor="#ffffff"
                />
        </LinearLayout>

    </RelativeLayout>
</LinearLayout>

有什么想法吗?

4

1 回答 1

2

您的父布局是线性的,在相对布局中更改它,如下面的代码

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/theme_black_bg" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/bottom_bar"
        android:layout_below="@+id/top_bar"
        android:layout_marginTop="15dip"
        android:gravity="center_horizontal"
        android:orientation="vertical" >
        <LinearLayout
            android:id="@+id/linearlayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/email_edit_bg"
            android:gravity="center_horizontal"
            android:orientation="vertical" >
            <EditText
                android:id="@+id/LoginEmailAddressEditTextView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:background="@drawable/edit_text_bg"
                android:ems="2"
                android:hint="Please enter email"
                android:paddingLeft="5dip"
                android:paddingRight="5dip"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:singleLine="true"
                android:textColor="@color/label_color_white"
                android:textColorHint="#FFFFFFFF"
                android:textSize="12sp" />

        </LinearLayout>
        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dip"
            android:layout_marginTop="10dip"
            android:background="@drawable/separator_bg" />
        <EditText
            android:id="@+id/LoginPasswordEditTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/edit_text_bg"
            android:ems="2"
            android:hint="@string/hint_password"
            android:inputType="textPassword"
            android:paddingLeft="5dip"
            android:paddingRight="5dip"
            android:singleLine="true"
            android:textColor="@color/label_color_white"
            android:textColorHint="#FFFFFFFF"
            android:textSize="12sp" />

        <Button
            android:id="@+id/LoginScreenLoginButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:background="@drawable/login_btn_selector" />
        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dip"
            android:layout_marginTop="10dip"
            android:background="@drawable/separator_bg" />
        <Button
            android:id="@+id/LoginScreenForgotPasswordButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:background="@drawable/forgot_password_btn_selector" />
    </LinearLayout>
    <include
        android:id="@+id/bottom_bar"
        android:layout_alignParentBottom="true"
        layout="@layout/bottom_advertisement_merge_layout" />
</RelativeLayout>
于 2013-02-09T04:24:35.543 回答