Actionbar gets hidden when i use android:windowSof

2019-07-23 04:50发布

Manifest

    <activity
        android:name="com.example.Thread"
        android:label="Thread"
        android:windowSoftInputMode="adjustPan"
        android:parentActivityName="com.example.Home" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.Home" />
    </activity>

Layout XML file

<?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="match_parent"
android:background="#e3e3e3"
android:orientation="vertical" >

<View
    android:id="@+id/view2"
    android:layout_width="match_parent"
    android:layout_height="4dp"
    android:background="@color/green_line" />

<RelativeLayout
    android:id="@+id/bottom_layout"
    android:layout_width="match_parent"
    android:layout_height="55dp"
    android:background="#f0eeec"
    android:layout_alignParentBottom="true" >

    <ImageView
        android:id="@+id/camera"
        android:layout_width="55dp"
        android:layout_height="55dp"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:padding="16dp"
        android:src="@drawable/camera" />

    <ImageView
        android:id="@+id/send"
        android:layout_width="55dp"
        android:layout_height="55dp"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:padding="12dp"
        android:src="@drawable/abc_ic_go_search_api_holo_light" />

    <EditText
        android:id="@+id/chatContent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toLeftOf="@+id/send"
        android:layout_toRightOf="@+id/camera"
        android:ems="10" />

</RelativeLayout>

<ListView
    android:id="@+id/chatThread"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/bottom_layout"
    android:layout_below="@+id/view2"
    android:divider="@null"
    android:dividerHeight="0dp"
    android:layout_centerHorizontal="true" >

</ListView>

When the user invoke softkeyboard it is overlapping the listview so that the bottom items getting hidden by the same. if i give android:windowSoftInputMode="adjustPan" Listview going up to the keyboard but also hiding the actionbar.

I need the listview to go up but the ActionBar should stay there on top. How i can implement that? Please comment if need more clarification.

1条回答
Root(大扎)
2楼-- · 2019-07-23 05:32

try this

 android:windowSoftInputMode="adjustResize"

and declare your listview like this

ListView listView = (ListView) findViewById(R.id.list_view);
listView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
listView.setStackFromBottom(true);

i hope this work for you and read this, it help in understanding of adjustPan and adjustResize

查看更多
登录 后发表回答