【问题标题】:Alert Dialog hidden behind soft-keyboard android隐藏在软键盘android后面的警报对话框
【发布时间】:2016-10-22 20:35:42
【问题描述】:

这是我的自定义警报对话框代码 -

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true"
        android:scrollbars="vertical">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/inset_background_dialog"
            android:padding="@dimen/dialog_elements_margin">

            <TextView
                android:id="@+id/text_add_address_title_addnewaddress"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_alignParentTop="true"
                android:text="@string/add_new_address_title_addnewaddress"
                android:textAppearance="?android:attr/textAppearanceMedium"/>

            <ImageView
                android:id="@+id/image_close_dialogue_addnewaddress"
                android:layout_width="@dimen/dialog_close_button"
                android:layout_height="@dimen/dialog_close_button"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:layout_marginTop="4dp"
                android:src="@drawable/ic_unchecked_black"/>

            <EditText
                android:id="@+id/edit_address_title_addnewaddress"
                style="@style/roundedEditText"
                android:layout_below="@+id/text_add_address_title_addnewaddress"
                android:hint="@string/address_title_hint_addnewaddress"/>

            <EditText
                android:id="@+id/edit_mobile_number_addnewaddress"
                style="@style/roundedEditText"
                android:layout_below="@+id/edit_address_title_addnewaddress"
                android:hint="@string/mobile_number_hint_addnewaddress"
                android:inputType="number"/>

            <EditText
                android:id="@+id/edit_apartment_no_addnewaddress"
                style="@style/roundedEditText"
                android:layout_below="@+id/edit_mobile_number_addnewaddress"
                android:hint="@string/house_no_hint_addnewaddress"/>

            <EditText
                android:id="@+id/edit_landmark_addnewaddress"
                style="@style/roundedEditText"
                android:layout_below="@+id/edit_apartment_no_addnewaddress"
                android:hint="@string/landmark_hint_addnewaddress"/>

            <EditText
                android:id="@+id/edit_location_addnewaddress"
                style="@style/roundedEditText"
                android:layout_below="@+id/edit_landmark_addnewaddress"
                android:hint="@string/address_hint_addnewaddress"/>

            <Button
                android:id="@+id/save_address_addnewaddress"
                android:layout_width="match_parent"
                android:layout_height="@dimen/dialog_elements_height"
                android:layout_below="@+id/edit_location_addnewaddress"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="@dimen/dialog_elements_margin"
                android:background="@drawable/add_button_back_about_product"
                android:text="@string/save_address_button_addnewaddress"
                android:textAllCaps="false"
                android:textColor="@color/tabSelectedTextColor"/>
            </RelativeLayout>

    </ScrollView>

</RelativeLayout>

问题是,底部的编辑文本字段隐藏在软键盘后面。我尝试在特定活动中将 android 清单更新为 android:windowSoftInputMode="adjustResize" 但没有运气。有什么解决办法吗?

【问题讨论】:

  • 你可以删除主要的RelativeLayout,只使用滚动视图,然后至少用户可以向上移动屏幕。
  • 不,这很有用。
  • 如果您更改警报对话框的位置,可以吗?如果是,则将其设置为顶部。
  • 即使我将重力设置为 TOP,但按钮隐藏在键盘后面,我想更好的解决方案是让布局可滚动,我现在无法实现。跨度>
  • 在我在答案中发布代码时尝试此滚动视图

标签: android


【解决方案1】:
<ScrollView>
<LinearLayout android:orientation="vertical"
        android:scrollbars="vertical"
        android:scrollbarAlwaysDrawVerticalTrack="true">
    <EditView />
    <Button />
</LinearLayout>

在 LinearLayout 中设置您的 UI 并尝试。

【讨论】:

    猜你喜欢
    • 2012-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-23
    • 1970-01-01
    • 2011-08-29
    相关资源
    最近更新 更多