android 底部edittext,全屏使用工具栏和底部android的edittext

我正在使用聊天应用Android.

我正在创建聊天屏幕,就像Whats应用程序一样.

底部的EditText和顶部的工具栏.

我正在使用以下代码.

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@color/White"

android:id="@+id/llFrame">

android:layout_width="match_parent"

android:layout_height="?android:attr/actionBarSize"

android:background="@color/White"/>

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="#ffffff"

android:fitsSystemWindows="true"

android:orientation="vertical"

android:layout_marginTop="?android:attr/actionBarSize"

>

android:id="@+id/recyclerViewChat"

android:layout_width="wrap_content"

android:layout_height="0dp"

android:layout_weight="0.8"

android:divider="@null"

android:dividerHeight="0dp"

android:paddingBottom="10dp"

android:text="@string/hello_world"

android:layout_marginTop="@dimen/_5sdp"/>

android:id="@+id/form"

android:layout_width="match_parent"

android:layout_height="@dimen/_35sdp"

android:background="#91f1f1f1"

android:orientation="horizontal"

android:paddingBottom="2dp"

android:gravity="center">

android:layout_width="0dp"

android:layout_weight="0.8"

android:layout_height="match_parent"

android:layout_gravity="center_vertical"

android:gravity="center_vertical"

android:paddingRight="@dimen/_2sdp"

android:paddingLeft="@dimen/_10sdp"

android:paddingTop="@dimen/_2sdp"

android:paddingBottom="@dimen/_2sdp"

>

android:id="@+id/etMessage"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:ems="10"

android:background="@drawable/rectangle_"

android:padding="@dimen/_2sdp"

/>

android:id="@+id/tvSendMessage"

android:layout_width="0dp"

android:layout_weight="0.2"

android:layout_height="match_parent"

android:layout_margin="@dimen/_2sdp"

android:text="Send"

android:textSize="@dimen/_15sdp"

android:layout_gravity="center"

android:gravity="center"

/>

为了获得全屏活动,我在活动中使用以下代码.

requestWindowFeature(Window.FEATURE_NO_TITLE);

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN);

现在,当我点击底部的EditText时,软键盘会打开但是将上面的布局推到顶部,我无法看到工具栏.

相反,一旦用户打开edittext,工具栏就应固定在他的位置.

谢谢

解决方法:

请参阅下面的聊天布局示例.

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@color/white"

android:clickable="true"

android:orientation="vertical">

android:layout_width="match_parent"

android:layout_weight="1"

android:layout_height="0dp">

android:id="@+id/linearSmsLayout"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_margin="10dp"

android:paddingBottom="20dp"

android:orientation="vertical">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="end"

android:layout_marginBottom="10dp"

android:layout_marginLeft="120dp"

android:layout_marginRight="10dp"

android:layout_marginTop="10dp"

android:background="@drawable/ic_msg_icon_sender"

android:text="This is long text for testing only. This is long text for testing only. This is long text for testing only. This is long text for testing only. This is long text for testing only." />

android:id="@+id/txtReceiveMessage"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="start"

android:layout_marginBottom="10dp"

android:layout_marginLeft="10dp"

android:layout_marginRight="120dp"

android:layout_marginTop="10dp"

android:background="@drawable/ic_msg_icon_receiver"/>

android:layout_width="match_parent"

android:layout_height="1dp"

android:background="@color/grey_400" />

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_margin="10dp"

android:orientation="horizontal">

android:id="@+id/edtTxtSmsText"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:layout_marginRight="10dp"

android:layout_weight="1"

android:background="@color/grey_400"

android:hint="Write a message..."

android:padding="10dp" />

android:id="@+id/btnSendSms"

android:layout_width="40dp"

android:layout_height="40dp"

android:layout_gravity="center"

android:src="@drawable/ic_send_red" />

并且还在android Manifeast文件中使用android:windowSoftInputMode =“adjustResize”.

没有键盘.

7a45a3b8615bc7371adfc4e9919a8612.png

用键盘.

1081fc6d49c47de82f6d000e9257f569.png

标签:android,android-edittext,android-toolbar

来源: https://codeday.me/bug/20190823/1701943.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值