android - 键盘覆盖布局底部的搜索 View

标签 android keyboard

layout screen

list 文件 android:windowSoftInputMode="adjustPan|adjustResize|stateVisible" 当键盘显示和标题栏不应该熄灭时,我想在键盘顶部显示 serachview。有什么办法吗? XMl页面

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar
        android:id="@+id/progress1"
        style="@style/progressbar"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:layout_gravity="center"
        android:visibility="gone"
        app:mlpb_progress_color="@color/blue"
        app:mlpb_progress_stoke_width="3dp" />

    <!--<include
        android:id="@+id/layoutTitle"
        layout="@layout/title_bar" />-->

    <SearchView
        android:id="@+id/searchViewB"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:background="@color/row_bg_transparent_white"
        android:padding="2dp"

        android:queryHint="Search">

    </SearchView>

    <LinearLayout

        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/searchViewB"
        android:layout_alignEnd="@+id/searchViewB"
        android:layout_alignRight="@+id/searchViewB"
        android:layout_marginBottom="5dp"
        android:layout_marginTop="5dp"
        android:background="@drawable/layout_bg"
        android:focusableInTouchMode="true"
        android:orientation="vertical"
        android:padding="5dp">

        <ListView
            android:layout_width="match_parent"
            android:layout_height="match_parent"></ListView>

    </LinearLayout>
</RelativeLayout>

最佳答案

根据需要使用此布局修改,即使没有任何 android:windowSoftInputMode

enter image description here enter image description here

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <ProgressBar
        android:id="@+id/progress1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:layout_gravity="center"
        android:visibility="gone" />

    <SearchView
        android:id="@+id/searchViewB"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:padding="2dp"
        android:queryHint="Search" >
    </SearchView>

    <ListView
        android:id="@+id/serachitem"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/searchViewB" >
    </ListView>
</RelativeLayout>

我的 list

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.test"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="19"
        android:targetSdkVersion="21" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name="com.example.test.Layouts"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

我的 Activity 课

 package com.example.test;

    import java.util.ArrayList;

    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.ArrayAdapter;
    import android.widget.ListView;

    public class Layouts extends Activity {

        private ArrayList<String> some;
        private ListView list;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.searchview);

            some = new ArrayList<String>();
            for (int i = 0; i < 100; i++) {
                some.add("Item" + i);
            }

            list = (ListView) findViewById(R.id.serachitem);

            ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(),
                    android.R.layout.simple_list_item_1, some);

            list.setAdapter(adapter);
        }
    }

关于android - 键盘覆盖布局底部的搜索 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37021004/

相关文章:

android - 根据android中按钮点击的持续时间触发不同的方法

android - 布局在 StatusBar 和 Soft Keys 下

android.database.CursorIndexOutOfBoundsException : Index -1 requested, 大小为 1

android - 在 android 上使用 com.android.camera.action.CROP 裁剪保存的图像

keyboard - 键盘上的 Scroll Lock 按钮有什么用?

android - 我的 Android Studio 项目继续运行我的旧项目/应用程序

keyboard - 无法使用cvWaitKey()捕获键盘笔触

python - 从终端检测脚本中键盘输入的最简单方法是什么?

Android:当 EditText 输入类型为数字时键盘闪烁

ios - 在 IOS 中显示警报时,键盘不会从 View 中退出