Android软键盘隐藏了控件

时间:2015-07-28 00:22:33

标签: android android-layout android-softkeyboard

我知道有很多问题,但没有一个答案对我有用。打开键盘之前,这是一个有问题的屏幕。

enter image description here

这是通过点击EditText打开键盘后的屏幕,然后尽可能向下滚动。

How to Integrate Flot with AngularJS?

请注意,除了最终隐藏的最终编辑控件外,所有文本和后面的按钮都无法访问。

这是片段布局:

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

    <RelativeLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:paddingBottom="@dimen/activity_vertical_margin"
        tools:context=".MainActivity$PlaceholderFragment"
        android:background="@color/background">

        <TextView android:id="@+id/header"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/primary"
            android:text="@string/help_header"
            android:textSize="20sp"
            android:layout_marginLeft="@dimen/activity_horizontal_margin"
            android:layout_marginRight="@dimen/activity_horizontal_margin"
            />

        <TextView android:id="@+id/drop"
            android:layout_below="@id/header"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/help_sub_header"
            android:textSize="16sp"
            android:textColor="@color/material_drawer_secondary_text"
            android:layout_marginLeft="@dimen/activity_horizontal_margin"
            android:layout_marginRight="@dimen/activity_horizontal_margin"
            android:layout_marginBottom="@dimen/activity_vertical_margin"
            />

        <View android:id="@+id/divider1"
            android:layout_below="@id/drop"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@color/light_gray_background"
            android:layout_marginBottom="@dimen/activity_vertical_margin"/>

        <LinearLayout android:id="@+id/linear1"
            android:layout_below="@id/divider1"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin">

            <!-- Several EditTexts and such -->

        </LinearLayout>
    </RelativeLayout>
</ScrollView>

它最初是在LinearLayout中,我根据建议将其更改为RelativeLayout,但这并没有改变任何东西。我还使用前两个视图组级别的布局高度(wrap_content / match_parent)无效。以下是清单中的活动声明:

<activity
            android:name=".MainActivity"
            android:label="@string/application_name"
            android:windowSoftInputMode="adjustResize" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

我也尝试过adjustPan,它似乎没有改变。我并不太关心键盘打开时UI元素究竟是做什么的,我只想通过滚动来访问整个布局。

基本上每个人都指向软输入模式,但这似乎没有做任何事情。有什么关于我缺少的碎片吗?或者这可能比我期望的更难,我需要制作一个自定义布局类并测量布局和讨厌的东西吗?我可以添加活动布局,虽然它没有多少,或代码,如片段创建/交易的东西。

2 个答案:

答案 0 :(得分:0)

这就是键盘的功能。它覆盖了屏幕的底部。如果您希望它根本不覆盖您的应用,您可以使用adjustResize。这将扩展您的应用程序只绘制在上半部分。但是如果你的内容太大,它仍然不合适,它看起来就像你的应用程序被覆盖(即使它不是。通过滚动视图滚动它应该工作(虽然我&#39;从来没有真正试过它。)但是,当键盘启动时,你唯一能控制行为的就是softInputMode。

如果你有很多可调节的空间或空格,有些技术会让你有所收缩,可能会让你的完整应用程序出现在缩小的空间中。这不是这种情况,你在屏幕上有太多的东西(除了在肖像模式下的平板电脑上)。所以他们不会在这里申请。

答案 1 :(得分:0)

事实证明问题出在图书馆,材料抽屉(漂亮的图书馆)。对于其他遇到此问题的人:

https://github.com/mikepenz/MaterialDrawer/blob/master/README.md#i-have-problems-with-the-softkeyboard-how-can-i-fix-this

调用Drawer.keyboardSupportEnabled(this,true),布局将进行适当的排列和滚动。

相关问题