键盘隐藏视图

时间:2017-03-14 19:49:17

标签: android xml android-layout

我已经阅读了很多类似于我的问题,但所有人都在谈论

    清单中的
  • android:windowSoftInputMode
  • fitsSystemWindows在视图中
  • 添加滚动作为父视图

没有解决我的问题

我正在使用Collapsing toolbar layoutMini Drawer和我的XML,问题出在Fragment Class

这是XML代码

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          android:orientation="vertical"
          tools:context="project.learning.android.afinal.mapcreatelesson.ReportFragment"
>

<TextView
    android:id="@+id/textView2"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:text="TextView"
    />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:orientation="horizontal"
    >

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="3"
        >

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="hint"
            />

    </android.support.design.widget.TextInputLayout>

    <com.mikepenz.iconics.view.IconicsButton
        android:text="{gmd-send} Send"
        android:background="@drawable/circular_button"
        android:layout_weight="3"
        android:layout_width="100dp"
        android:layout_height="50dp"
        android:textColor="@color/material_drawer_dark_header_selection_text"
        app:ico_color="@color/material_drawer_dark_header_selection_text"
        />


</LinearLayout>

Surly正在从主要活动加载getSupportFragmentManager().beginTransaction()...FrameLayout

enter image description here

我们看到我的EditTextButton在布局中有gravity=bottom,当我按下EditText键盘弹出窗口隐藏EditText时按钮

提前致谢,请回答一下解释的答案或参考阅读以了解我的布局问题

更新

清单

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="project....mapcreatelesson">

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity"
              android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>

            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
    </activity>
    <activity
        android:name=".TestMainActivity"
        android:label="@string/title_activity_test_main"
        android:theme="@style/AppTheme.NoActionBar"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>

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

结果截图

enter image description here

2 个答案:

答案 0 :(得分:0)

我认为您应该将此行应用于清单文件:

android:windowSoftInputMode="adjustResize"

有关详细信息,您可以浏览以下链接 https://developer.android.com/training/keyboard-input/visibility.html

答案 1 :(得分:0)

[![As you can see the edittext and button is not hidden behind keyboard][1]][1]

Here is my AndroidManifest.xml file.

<application
        android:name=".AppController"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".Custom"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
  [1]: https://i.stack.imgur.com/8iI0M.png
相关问题