Java 显示键盘时,状态栏应保持在原来的位置
在whatsApp或google messenger中,状态栏不会在显示的键盘上向上滑动,Java 显示键盘时,状态栏应保持在原来的位置,java,android,xml,Java,Android,Xml,在whatsApp或google messenger中,状态栏不会在显示的键盘上向上滑动,ListView根据Edittext调整大小。根据stackoverflow中的一些研究,我在android:WindowsofInputMode中设置了AdjustResize属性。该属性调整列表视图的大小,但也向上滑动状态栏。我想要持久状态栏。我也尝试过android:fitsystemwindows=“true”,但没有用。我使用的是支持工具栏,而不是ActionBar和AppCompactActiv
ListView
根据Edittext
调整大小。根据stackoverflow中的一些研究,我在android:WindowsofInputMode
中设置了AdjustResize
属性。该属性调整列表视图的大小,但也向上滑动状态栏。我想要持久状态栏。我也尝试过android:fitsystemwindows=“true”
,但没有用。我使用的是支持工具栏
,而不是ActionBar
和AppCompactActivity
和Theme.AppCompact.Light.NoActionBar
主题
manifest.xml
<activity
android:name=".activities.ConversationActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize" />
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/re/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_conversation"
tools:context=".activities.ConversationActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/tb_conversation"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/white"
android:fitsSystemWindows="true"
android:gravity="center_horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/title_conversation"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/img_doctor"
android:layout_toStartOf="@+id/img_doctor"
android:gravity="center"
android:text="text"
android:textSize="20sp"
android:textStyle="normal" />
<com.views.CircularNetworkImageView
android:id="@+id/img_doctor"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:padding="10dp"
android:src="@drawable/ic_tab_profile" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/tb_conversation"
android:layout_centerHorizontal="true"
android:background="@color/colorAppGray" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/view">
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/view2"
android:divider="@null"
android:dividerHeight="0dp" />
<View
android:id="@+id/view2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_above="@+id/input_layout"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@color/colorAppGray" />
<RelativeLayout
android:id="@+id/input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:gravity="bottom"
android:layout_alignParentStart="true"
android:background="@android:color/white">
<EditText
android:id="@+id/et_msgInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="50dp"
android:layout_toLeftOf="@+id/btn_send_image"
android:layout_toStartOf="@+id/btn_send_image"
android:background="@drawable/res_bg_conversation_et"
android:gravity="center_vertical"
android:maxLines="5"
android:nextFocusLeft="@+id/btn_send_image"
android:nextFocusUp="@+id/btn_send_image"
android:paddingLeft="18dp"
android:paddingTop="18dp"
android:paddingBottom="18dp"
android:paddingRight="10dp"
android:scrollbars="vertical"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="@android:color/black" />
<ImageButton
android:id="@+id/btn_send_image"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@android:color/transparent"
android:focusable="true"
android:focusableInTouchMode="true"
android:padding="20dp"
android:src="@drawable/ic_camera"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<TextView
android:id="@+id/txt_send_msg"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_alignBottom="@+id/et_msgInput"
android:layout_toRightOf="@+id/et_msgInput"
android:gravity="center"
android:text="Gonder"
android:visibility="invisible" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
图像
第一眼
单击编辑文本后,将显示键盘
预期(状态栏保留在原来的位置)
发生(状态栏滑出视图):(
使用下面的代码在manifest.xml中进行更改
<activity
android:name=".activities.ConversationActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" />
我还建议使用如下图片中的片段
尝试添加此
<activity
android:name="com.app.name"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible|adjustPan"/>
尝试不添加输入模式
<activity
android:name="com.app.name"
android:screenOrientation="portrait"
/>
为我工作你可以试试奇特朗的解决方案
他已经把你所有的代码都放好了,而且似乎对他很有效,仅仅通过删除我就找到了解决问题的方法。问题不在于调整大小或调整span
。问题在于活动
全屏。在全屏活动
中,键盘的调整机构不起作用expected.@J.Chomel code added.。请回顾一下我们现在有什么需要考虑的,谢谢Bilal!也谢谢你给我这个宝贵的建议。现在我的问题更多的是关于解决方案。:)你的问题与我的非常相似。你尝试过它的解决方案吗?你能发布一些关于你行为的图片或演示视频吗?因为我已经尝试了你的代码,状态栏没有问题。为什么stateVisible
?我不想在活动开始时显示键盘,因此无法使用stateVisible
。我已经试过了。还没解决呢。@Bilal Haider Makki,你试过Chitrang的解决方案吗?@JChomel是的,试过了。没用。我已经尝试了这里给出的所有解决方案(我想这是主题的问题。你说呢?我对它一无所知:)我只是想通过吸引更多的注意力来帮助一个新来者。。。如果可能的话,你应该对每个答案进行评论,这样人们就会得到通知并尝试改进他们的答案。@Elesh,你知道为什么比拉尔的问题还没有解决吗?我想在颁发奖金之前知道这一点。好吧,我们为比拉尔做了我们能做的。谢谢你,埃利什!
<activity
android:name="com.app.name"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible|adjustPan"/>
<activity
android:name="com.app.name"
android:screenOrientation="portrait"
/>