键盘覆盖布局底部的searchview

时间:2016-05-04 07:21:38

标签: android keyboard

layout screen

清单文件  机器人: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>

4 个答案:

答案 0 :(得分:1)

这是工作样本。尝试使用这样的。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
>

<EditText
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:hint="New Text"
    android:id="@+id/textView"
    android:layout_alignParentTop="true"/>

<SearchView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/searchView"
    android:layout_alignParentBottom="true"/>


</RelativeLayout>

,您的manifest.xml是,

android:windowSoftInputMode="adjustResize"

答案 1 :(得分:1)

根据需要使用此布局修改,即使没有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>

我的清单

<?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>

我的活动课

 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);
        }
    }

答案 2 :(得分:0)

您只需将活动的windowSoftInputMode标记切换为&#34; adjustPan&#34;。

<activity
   ...
   android:windowSoftInputMode="adjustPan"> 
</activity>

查看official documentation了解详情。

答案 3 :(得分:0)

尝试使用它。

<activity
   ...
   android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
...> 
</activity>