Мне нравится интегрировать раздел комментариев в нижний лист. В разделе комментариев у меня есть recyclerView, который показывает все комментарии и EditText, который расположен в нижней части представления. когда нижний лист открыт в свернутом состоянии, текст редактирования не отображается, но когда состояние расширено, отображается текстовый макет редактирования. поэтому мне нужна помощь, чтобы показать опцию редактирования текста в каждом штате.
Это свернутое состояние Image
Это расширенное изображение состояния
Я хочу показать Редактировать текст в режиме свертывания так же, как настроение Expended.
XML Layout
<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="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".fragment.CommentFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:scrollingCache="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_main"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
<View
android:layout_width="fill_parent"
android:layout_height="?attr/actionBarSize">
</View>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:background="#fff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
<View
android:background="#B1B1B1"
android:layout_width="match_parent"
android:layout_height="1dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
Код
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final BottomSheetDialog dialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
dialog.getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE|
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
final View view = View.inflate(getContext(), R.layout.fragment_comment, null);
unbinder = ButterKnife.bind(this, view);
dialog.setContentView(view);
mBehavior = BottomSheetBehavior.from((View) view.getParent());
mBehavior.setPeekHeight(BottomSheetBehavior.PEEK_HEIGHT_AUTO);
mBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
mBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (BottomSheetBehavior.STATE_EXPANDED == newState) {
Log.d(TAG, "onStateChanged: STATE_EXPANDED");
}
if (BottomSheetBehavior.STATE_COLLAPSED == newState) {
Log.d(TAG, "onStateChanged: STATE_COLLAPSED");
}
if (BottomSheetBehavior.STATE_HIDDEN == newState) {
Log.d(TAG, "onStateChanged: STATE_HIDDEN");
dismiss();
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
}
});
commentsAdapterNew = new CommentsAdapterNew(getActivity(), commentsClassList);
RecyclerView.LayoutManager mManager = new LinearLayoutManager(getActivity(), RecyclerView.VERTICAL, true);
rvMain.setLayoutManager(mManager);
rvMain.setAdapter(commentsAdapterNew);
ViewCompat.setNestedScrollingEnabled(rvMain, false);
getAllComment("876");
return dialog;
}