项目中利用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>