我正在开发一个应用程序,我发现一个问题,键盘隐藏EditText字段。在研究中,我通过在清单文件中添加这行代码找到了解决方案。键盘覆盖编辑文本的一半Android
android:windowSoftInputMode="adjustPan"
的表情图标,编辑文本和发送的TextView是一个线性布局。我如何显示键盘上方的整个线性布局?
我正在开发一个应用程序,我发现一个问题,键盘隐藏EditText字段。在研究中,我通过在清单文件中添加这行代码找到了解决方案。键盘覆盖编辑文本的一半Android
android:windowSoftInputMode="adjustPan"
的表情图标,编辑文本和发送的TextView是一个线性布局。我如何显示键盘上方的整个线性布局?
我有完全一样的问题adjustPan
所以我用这个代替..
android:windowSoftInputMode="adjustResize"
我希望你的根布局RelativeLayout
。
UPDATE
尝试设置这样的。
chat_ui.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/chat_layout"
android:background="@color/white">
<android.support.design.widget.AppBarLayout
android:id="@+id/applayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/white"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<TextView
android:id="@+id/txtTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:gravity="center_horizontal"
android:text="Francis"
android:textColor="@color/page_background"
android:textSize="10pt" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<ListView
android:layout_below="@id/applayout"
android:id="@+id/chat_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottomlayout"
android:layout_marginBottom="4dp"
android:clipToPadding="false"
android:divider="@drawable/chat_divider"
android:paddingBottom="4dp"
android:paddingTop="8dp"
android:scrollbarStyle="outsideOverlay"
android:stackFromBottom="false"
android:transcriptMode="normal" />
<LinearLayout
android:id="@+id/bottomlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:background="@drawable/input"
android:minHeight="50dp"
android:orientation="horizontal"
android:paddingBottom="15dp"
android:paddingLeft="12dp"
android:paddingRight="20dp">
<!-- <ImageView
android:id="@+id/emojiButton"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="bottom"
android:src="@drawable/input_emoji" />-->
<EditText
android:id="@+id/chat_edit_text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="12dp"
android:background="@null"
android:hint="@string/type_message"
android:inputType="textMultiLine"
android:singleLine="false"
android:textColorHint="#c4c0bd"
android:textSize="18sp" />
</LinearLayout>
<ImageButton
android:id="@+id/enter_chat1"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:background="@drawable/input_circle_normal"
app:srcCompat="@drawable/ic_send" />
</LinearLayout>
</RelativeLayout>
和清单
<activity
android:name=".activities.ChatActivity"
android:windowSoftInputMode="stateHidden|adjustResize"
android:screenOrientation="portrait"
android:theme="@style/MyMaterialTheme2" />
试过了,没有工作:(它完全覆盖了我的editText –
检查我的更新..其我的聊天应用程序的工作代码,其工作良好在我的moto-g4加上牛轧糖版本 –
没有为我工作:(感谢更新的答案,虽然 –
设置机器人:softInputMode属性在舱单adjustResize,并把布局(未列出的项目布局)滚动型内。
对不起,我不明白最后一部分“把布局(不列表项目布局)“ –
我的意思是如果你已经使用了listview,那么不要把scrollview放到listview的布局中,你可能会忽略它,请把layout的scrollview放在那个edittext框里,发送按钮,所有的都来。 –
希望这[答案](http://stackoverflow.com/a/28012530/2347794)帮助你.... – Safa