【问题标题】:Actionbar gets hidden when i use android:windowSoftInputMode="adjustPan"当我使用 android:windowSoftInputMode="adjustPan" 时操作栏被隐藏
【发布时间】:2014-10-28 21:48:48
【问题描述】:

清单

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

布局 XML 文件

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

当用户调用软键盘时,它与列表视图重叠,因此底部项目被相同的隐藏。如果我给android:windowSoftInputMode="adjustPan" Listview 到键盘但也隐藏操作栏。

我需要列表视图上升,但 ActionBar 应该保持在顶部。我怎样才能实现呢?如果需要更多说明,请发表评论。

【问题讨论】:

  • 请注意 android:windowSoftInputMode="adjustResize" 不起作用。我也试过了

标签: android android-actionbar


【解决方案1】:

试试这个

 android:windowSoftInputMode="adjustResize"

并像这样声明您的列表视图

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

我希望这对你有用并阅读this,它有助于理解adjustPan和adjustResize

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-14
    • 1970-01-01
    • 2012-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-18
    • 1970-01-01
    相关资源
    最近更新 更多