我的片段布局文件如下
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- Top card -->
<android.support.v7.widget.CardView
android:id="@+id/new_store_visit_cv_top_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fadingEdgeLength="@dimen/d8dp"
app:cardCornerRadius="@dimen/d0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatTextView
android:layout_width="@dimen/d0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="4.5"
android:ellipsize="end"
android:fontFamily="@font/texgyreheros_regular"
android:lines="@integer/one"
android:paddingBottom="@dimen/d16dp"
android:paddingStart="@dimen/d10dp"
android:paddingTop="@dimen/d14dp"
android:text="@string/in_progress_store_visit"
android:textSize="@dimen/d16sp" />
<android.support.v7.widget.AppCompatImageButton
android:id="@+id/new_store_visit_ib_compare"
android:layout_width="@dimen/d0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="@android:color/transparent"
android:padding="@dimen/d10dp"
android:src="@drawable/ic_compare" />
<View
android:layout_width="@dimen/d0.5dp"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/margin_default"
android:layout_marginTop="@dimen/margin_default"
android:background="@color/pinkish_grey" />
<android.support.v7.widget.AppCompatImageButton
android:id="@+id/new_store_visit_ib_share"
android:layout_width="@dimen/d0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="@android:color/transparent"
android:padding="@dimen/d10dp"
android:src="@drawable/ic_share" />
<android.support.v7.widget.AppCompatButton
android:id="@+id/new_store_visit_bt_submit"
android:layout_width="@dimen/d0dp"
android:layout_height="@dimen/d30dp"
android:layout_gravity="center"
android:layout_marginEnd="@dimen/d10dp"
android:layout_weight="2.5"
android:background="@drawable/bg_button_enabled_small"
android:fontFamily="@font/texgyreheros_regular"
android:paddingBottom="@dimen/d4dp"
android:text="@string/submit"
android:textAlignment="center"
android:textAllCaps="false"
android:textColor="@android:color/white"
android:textSize="@dimen/d14sp" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v4.widget.NestedScrollView
android:id="@+id/new_store_visit_scroll_view_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/new_store_visit_cv_top_card"
android:overScrollMode="never">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="@+id/new_store_visit_cv_dashboard"
layout="@layout/layout_sales_compare" />
<include
android:id="@+id/new_store_visit_cv_checklist"
layout="@layout/layout_store_visit_checklist"
android:visibility="gone" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<include
android:id="@+id/new_store_visit_cv_help_pop_up"
layout="@layout/layout_help_text_pop_up"
android:visibility="gone" />
</RelativeLayout>
我的store_visit_checklist_layout如下
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/d10dp"
android:layout_marginEnd="@dimen/d8dp"
android:layout_marginStart="@dimen/d8dp"
android:layout_marginTop="@dimen/d10dp"
app:cardCornerRadius="@dimen/d8dp"
app:cardUseCompatPadding="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/store_visit_card_tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/texgyreheros_regular"
android:padding="@dimen/margin_default_card"
android:text="@string/store_visit"
android:textColor="@color/greyish_brown_two"
android:textSize="@dimen/d14sp" />
<android.support.v7.widget.AppCompatTextView
android:id="@+id/store_visit_card_tv_clear_all"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:fontFamily="@font/texgyreheros_regular"
android:padding="@dimen/margin_default_card"
android:text="@string/clear_all"
android:textColor="@color/colorAccent"
android:textSize="@dimen/d12sp" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/d0.5dp"
android:layout_below="@id/store_visit_card_tv_title"
android:layout_marginEnd="@dimen/margin_default_card"
android:layout_marginStart="@dimen/margin_default_card"
android:background="@color/pinkish_grey" />
<android.support.v7.widget.RecyclerView
android:id="@+id/store_visit_card_rv_checklist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/store_visit_card_tv_title"
android:layout_margin="@dimen/d10dp"
android:visibility="visible"
tools:itemCount="2"
tools:listitem="@layout/item_store_visit_checklist" />
</RelativeLayout>
</android.support.v7.widget.CardView>
我的item_store_visit_checklist如下
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/d10dp"
android:background="@drawable/bg_checklist">
<android.support.v7.widget.AppCompatImageButton
android:id="@+id/item_store_visit_ib_dropdown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:paddingBottom="@dimen/d20dp"
android:paddingEnd="@dimen/margin_default_card"
android:paddingStart="@dimen/margin_default"
android:paddingTop="@dimen/d20dp"
android:src="@drawable/ic_arrow_grey" />
<android.support.v7.widget.AppCompatTextView
android:id="@+id/item_store_visit_tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/item_store_visit_ib_dropdown"
android:layout_alignTop="@id/item_store_visit_ib_dropdown"
android:layout_toEndOf="@id/item_store_visit_ib_dropdown"
android:fontFamily="@font/texgyreheros_regular"
android:gravity="center_vertical"
android:text="People Management"
android:textColor="@color/greyish_brown"
android:textSize="@dimen/d14sp" />
<android.support.v7.widget.AppCompatImageButton
android:id="@+id/item_store_visit_ib_help"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/item_store_visit_tv_title"
android:background="@android:color/transparent"
android:paddingBottom="@dimen/d20dp"
android:paddingEnd="@dimen/d12dp"
android:paddingStart="@dimen/d12dp"
android:paddingTop="@dimen/d24dp"
android:src="@drawable/ic_help" />
<android.support.v7.widget.AppCompatTextView
android:id="@+id/item_store_visit_tv_comment_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toStartOf="@id/item_store_visit_iv_comments"
android:fontFamily="@font/texgyreheros_regular"
android:paddingBottom="@dimen/d14dp"
android:paddingStart="@dimen/d10dp"
android:paddingTop="@dimen/d14dp"
android:text="0"
android:textColor="@color/pinkish_grey"
android:textSize="@dimen/d14sp" />
<android.support.v7.widget.AppCompatImageView
android:id="@+id/item_store_visit_iv_comments"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:paddingBottom="@dimen/d20dp"
android:paddingEnd="@dimen/d10dp"
android:paddingStart="@dimen/d10dp"
android:paddingTop="@dimen/d20dp"
android:src="@drawable/ic_comment_empty" />
<LinearLayout
android:id="@+id/item_store_visit_ll_add_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/item_store_visit_ib_dropdown"
android:orientation="vertical"
android:visibility="gone">
<View
android:layout_width="match_parent"
android:layout_height="@dimen/d0.5dp"
android:background="@color/pinkish_grey" />
<android.support.v7.widget.AppCompatEditText
android:id="@+id/item_store_visit_et_add_comment"
android:layout_width="match_parent"
android:layout_height="@dimen/d60dp"
android:layout_marginBottom="@dimen/d10dp"
android:layout_marginEnd="@dimen/d10dp"
android:layout_marginStart="@dimen/d10dp"
android:layout_marginTop="@dimen/margin_default"
android:background="@drawable/bg_add_comment"
android:gravity="top"
android:hint="@string/add_comment_hint"
android:inputType="text|textMultiLine"
android:padding="@dimen/d10dp"
android:textSize="@dimen/d12sp" />
<android.support.v7.widget.AppCompatButton
android:id="@+id/item_store_visit_bt_add_comment"
android:layout_width="wrap_content"
android:layout_height="@dimen/d20dp"
android:layout_gravity="end"
android:layout_marginEnd="@dimen/d10dp"
android:background="@drawable/bg_button_white_blue_stroke"
android:minWidth="@dimen/d85dp"
android:text="Add"
android:textAllCaps="false"
android:textColor="@color/colorAccent"
android:textSize="@dimen/d10sp" />
</LinearLayout>
<RelativeLayout
android:id="@+id/item_store_visit_rl_comments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/item_store_visit_ll_add_comment"
android:visibility="gone">
<View
android:layout_width="@dimen/d2dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/item_store_visit_rv_comments"
android:layout_alignTop="@id/item_store_visit_rv_comments"
android:layout_marginStart="@dimen/d8dp"
android:layout_marginTop="@dimen/d10dp"
android:background="@color/warm_grey_two_14" />
<android.support.v7.widget.RecyclerView
android:id="@+id/item_store_visit_rv_comments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/d10dp"
android:overScrollMode="never"
android:descendantFocusability="beforeDescendants"
tools:itemCount="2"
tools:listitem="@layout/item_store_visit_comment" />
</RelativeLayout>
</RelativeLayout>
当我单击editText“ item_store_visit_et_add_comment”时,会出现问题,它会被键盘遮盖。我已经尝试将adjustPan和adjustResize设置为我的活动,但是没有任何效果。 我想要的是,editText应该滚动,以便在键盘上方可见。
对于tl; dr类型的人,其布局类似于:
<RelativeLayout>
<NestedScrollView>
<layout1/>
<layout2>
<RecyclerView>
<EditText/>
</RecyclerView>
</layout2>
</NestedScrollView>
</RelativeLayout>
答案 0 :(得分:0)
解决方案:
在您的Recyclerview中:
添加此属性:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.6.2.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<version>3.6.2.Final</version>
<scope>provided</scope>
</dependency>
您的问题将得到解决。
希望有帮助。