RecyclerView中放入EditText出现的问题

项目中利用RecyclerView实现下图展示的功能:
这里写图片描述
写完了布局,买家留言部分用的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>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值