#android #android-recyclerview
#Android #android-recyclerview
Вопрос:
В RecyclerView есть EditText, и когда я нажимаю на EditText, мой RecyclerView перемещается вверх, но проблема в том, что макет над RecyclerView также перемещается вверх и не прокручивается вниз, поэтому он не будет полностью видимым, если клавиатура не переключается, хотя RecyclerView прокручивается правильно.В манифесте я установил android: windowSoftInputMode =»adjustPan» Мой фрагмент макета
<?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="match_parent"
android:padding="14dp">
<!-- <ScrollView
android:id="@ id/scroll_rec"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:id="@ id/linear"
android:orientation="vertical">
-->
<LinearLayout
android:id="@ id/sender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentTop="true"
android:padding="5dp">
<TextView
android:id="@ id/sender_info"
style="@style/MyTextViewStyleRed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Heading"
android:textAllCaps="true"
android:textSize="@dimen/receiver" />
<RelativeLayout
android:id="@ id/user_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@ id/sender_info">
<LinearLayout
android:id="@ id/linear1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:orientation="vertical">
<TextView
android:id="@ id/txt_cust_id"
style="@style/MyTextViewStyleBlack"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="name"
android:textSize="@dimen/home_size" />
<TextView
android:id="@ id/txt_mobile_number"
style="@style/MyTextViewStyleBlack"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:text="email"
android:textSize="@dimen/home_size" />
<TextView
android:id="@ id/txt_amount_dialog"
style="@style/MyTextViewStyleBlack"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:text="comment"
android:textSize="@dimen/home_size" />
</LinearLayout>
<LinearLayout
android:id="@ id/linear2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/linear1"
android:orientation="vertical">
<TextView
android:id="@ id/colon_id"
style="@style/MyTextViewStyleBlack"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text=":"
android:textSize="@dimen/home_size" />
<TextView
android:id="@ id/colon_mobile"
style="@style/MyTextViewStyleBlack"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:text=":"
android:textSize="@dimen/home_size" />
<TextView
android:id="@ id/colon_amount"
style="@style/MyTextViewStyleBlack"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:text=":"
android:textSize="@dimen/home_size" />
</LinearLayout>
<LinearLayout
android:id="@ id/l1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@ id/linear2"
android:orientation="vertical">
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbarFadeDuration="0"
android:scrollbarSize="2px"
android:scrollbarThumbHorizontal="@drawable/thumb_scroll">
<TextView
android:id="@ id/tv_name"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:scrollHorizontally="true"
android:text="abc"
android:textSize="@dimen/home_size" />
</HorizontalScrollView>
<!--<TextView
android:id="@ id/tv_name"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:ellipsize="end"
android:singleLine="true"
android:text="sankalp sankalp(9987345231))"
android:textColor="@android:color/black" />-->
<TextView
android:id="@ id/tv_kyc_status"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:text="xyz"
android:textSize="@dimen/home_size" />
<TextView
android:id="@ id/tv_monthly_limit"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:text="250000"
android:textSize="@dimen/home_size" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<!--<Button
android:id="@ id/btn_transfer"
style="@style/MyTextViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@ id/sender"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:background="@drawable/button_maroon"
android:drawableLeft="@drawable/ic_transfer"
android:drawablePadding="3dp"
android:gravity="top"
android:minHeight="0dp"
android:minWidth="0dp"
android:padding="5dp"
android:text="Add Receiver"
android:textColor="@android:color/white"
android:textSize="@dimen/home_size" />-->
<Button
android:id="@ id/btn_transfer"
style="@style/MyTextViewStyleButton"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_below="@ id/sender"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:background="@drawable/button_maroon"
android:gravity="center"
android:padding="5dp"
android:text="Add"
/>
<View
android:id="@ id/view"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="@id/btn_transfer"
android:background="@color/colorPrimary"></View>
<!-- </LinearLayout>
</ScrollView>
-->
<android.support.v7.widget.RecyclerView
android:id="@ id/rv_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/view"
android:transcriptMode="normal"
android:layout_marginTop="10dp"></android.support.v7.widget.RecyclerView>
<TextView
android:id="@ id/txt_empty"
style="@style/MyTextViewStyleRed"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:scrollbars="vertical"
android:text="@string/NoInternet"
android:visibility="gone"></TextView>
</RelativeLayout>
Комментарии:
1. попробуйте использовать :
android:windowSoftInputMode="adjustResize"
вместо.2. Большое спасибо, это сработало, перепробовал все комбинации, прежде чем ни одна из них не сработала
3. Еще одна вещь, когда я прокручиваю RecyclerView edittext теряет фокус, значение в editext остается неизменным, хотя
Ответ №1:
Добавьте android:windowSoftInputMode=»adjustNothing» в тег activity на manifest.xml