RecyclerView中放入EditText出现的问题
2017-08-05 15:29
561 查看
项目中利用RecyclerView实现下图展示的功能:
![](https://oscdn.geek-share.com/Uploads/Images/Content/202008/16/bcf5fbc0d08a8699a102d47e4f6bb103)
写完了布局,买家留言部分用的EditText,默认键盘不弹出,所以在AndroidManifest.xml中,设置了该Activity的属性:
运行后出现的问题:有时收货那部分会向上缩紧了些,被标题给覆盖了。
![](https://oscdn.geek-share.com/Uploads/Images/Content/202008/16/e01f6d2e990ec5b748bc0255c2fb8d9b)
本以为是逻辑代码的问题,测试了很多遍,都没有改变过来,今天突然想到。进入这个页面EditText就直接获取焦点了,会不会是这个影响呢,找了一下,将中间商品布局中EditText的根部句添加两行代码,将它改为不获取焦点,运行后问题解决:
xml代码如下:
写完了布局,买家留言部分用的EditText,默认键盘不弹出,所以在AndroidManifest.xml中,设置了该Activity的属性:
<activity android:name=".activity.ShopCartSureIndentActivity" android:windowSoftInputMode="adjustPan|stateHidden" />
运行后出现的问题:有时收货那部分会向上缩紧了些,被标题给覆盖了。
本以为是逻辑代码的问题,测试了很多遍,都没有改变过来,今天突然想到。进入这个页面EditText就直接获取焦点了,会不会是这个影响呢,找了一下,将中间商品布局中EditText的根部句添加两行代码,将它改为不获取焦点,运行后问题解决:
android:focusable="true" android:focusableInTouchMode="true"
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="wrap_content"
android:focusable="true" android:focusableInTouchMode="true"
>
<TextView
android:id="@+id/delivery_sureMoney"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/ten_dp"
android:layout_marginTop="@dimen/five_dp"
android:text="配送方式:快递"
android:textColor="@color/muchDeep_color"
android:textSize="@dimen/fourteen_size" />
<TextView
android:id="@+id/freight_sureMoney"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="@dimen/twentyFive_dp"
android:layout_marginTop="@dimen/five_dp"
android:text="运费:¥0.00"
android:textColor="@color/muchDeep_color"
android:textSize="@dimen/fourteen_size" />
<TextView
android:id="@+id/sendMessageText_sureMoney"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/freight_sureMoney"
android:layout_marginLeft="@dimen/ten_dp"
android:layout_marginTop="@dimen/ten_dp"
android:text="@string/shopSure_sendMessage"
android:textColor="@color/muchDeep_color"
android:textSize="@dimen/fourteen_size" />
<EditText
android:id="@+id/sendMessageEdit_sureMoney"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/sendMessageText_sureMoney"
android:layout_below="@id/freight_sureMoney"
android:layout_marginRight="@dimen/ten_dp"
android:layout_marginTop="@dimen/ten_dp"
android:layout_toRightOf="@id/sendMessageText_sureMoney"
android:background="@color/white"
android:hint="@string/shopSure_hintMessage"
android:textSize="@dimen/twelve_size"
android:maxLines="2"
android:textColorHighlight="@color/commonDeep_color"
android:textColorHint="@color/commonDeep_color" />
<TextView
android:id="@+id/line1_sureMoney"
style="@style/SureIndentLine"
android:layout_below="@id/sendMessageEdit_sureMoney"
android:layout_marginTop="@dimen/ten_dp" />
<RelativeLayout
android:id="@+id/rlTotalMoney_sureMoney"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/line1_sureMoney"
android:layout_marginBottom="@dimen/ten_dp"
android:layout_marginTop="@dimen/ten_dp"
android:gravity="center">
<TextView
android:id="@+id/goodNum_sureMoney"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="共1件商品"
android:textColor="@color/muchDeep_color"
android:textSize="@dimen/fourteen_size" />
<TextView
android:id="@+id/payMoney_sureMoney"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/ten_dp"
android:layout_toRightOf="@id/goodNum_sureMoney"
android:text="@string/shopSure_payMoney"
android:textColor="@color/muchDeep_color"
android:textSize="@dimen/fourteen_size" />
<TextView
android:id="@+id/payPrice_sureMoney"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/ten_dp"
android:layout_toRightOf="@id/payMoney_sureMoney"
android:text="510元"
android:textColor="@color/mainRed_color"
android:textSize="@dimen/fourteen_size" />
</RelativeLayout>
<TextView
style="@style/SureIndentLine"
android:layout_below="@id/rlTotalMoney_sureMoney" />
</RelativeLayout>
相关文章推荐
- listview或recyclerView嵌套edittext出现复用问题的解决方式
- EditText和TextView出现中文、英文等string串的排版问题
- Android ListView/recyclerView条目中EditText容易失去焦点的问题和取出横向时上下滚动有阴影
- RecyclerView嵌套多个布局,多个editText,解决文本输入框上下交换位置中的值问题
- EditText和TextView出现中文、英文等string串的排版问题
- RecyclerView.Adapter的某个item中EditText的输入后所有列表中Editetext全部被修改的问题
- 水平RecyclerView中Item中含有EditText问题
- RecyclerView之crash 和 EditText数据重置问题
- RecyclerView的item中有EditText的问题
- 当EditText做Recyclerview头部时,界面绘制好后发现Recyclerview向上滚动了一点的问题
- 基础向:recyclerView 内嵌 edittext checkbox 焦点获取、数据紊乱以及数据保存问题
- 关于listview或者recyclerview里面的edittext数据保存问题
- RecyclerView EditText 数据错乱问题
- RecyclerView中EditText数据混乱,FoldingCell折叠布局第一次点击有问题
- Android中findViewById()获取EditText 空指针问题
- 关于EditText与ScrollView嵌套使用时候出现的Edittext自动滚动至最顶部的问题
- 关于android开发ListView的Adapter的convertView中有EditText的问题
- Android View 焦点问题(EditText clearFocus)
- Android ScrollView 中放入 ImageView 导致的出现上下白边的问题?
- 处理RecyclerView中嵌套EditText数据显示混乱