Tôi đang cố gắng tạo RelativeLayout có CoordinatorLayout và LinearLayout ở phía dưới và tìm thấy một số hành vi lạ mà tôi không thể giải quyết. Đây là cách bố trí của tôiRecycleview trong coordinatorlayout
<?xml version="1.0" encoding="utf-8"?>
<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.support.design.widget.CoordinatorLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/sender"
android:background="@android:color/white"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:background="?colorPrimary"
app:layout_scrollFlags="scroll|enterAlways" />
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/messages_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
<LinearLayout
android:id="@+id/sender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center_vertical"
android:background="@android:color/white">
<EditText
android:id="@+id/inputText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="text" />
<Button
android:fontFamily="sans-serif"
style="?android:attr/borderlessButtonStyle"
android:textAppearance="?android:textAppearanceButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/send"
android:textColor="?colorPrimary"
android:id="@+id/send"/>
</LinearLayout>
</RelativeLayout>
Sau khi thay đổi dữ liệu trong bộ chuyển đổi tôi cố gắng để di chuyển đến yếu tố cuối cùng (ví dụ bằng cách recyclerView.smoothScrollToPosition (size);) và tất cả tôi thấy là một phần của quan điểm cuối cùng (kích thước không đầy đủ). Nếu recycleview không lồng vào CoordinatorLayout - tất cả đều hoạt động như mong đợi - tôi thấy toàn bộ kích thước phần tử cuối cùng. Làm cách nào tôi có thể thay đổi bố cục để hoạt động chính xác?
gì là kỳ vọng và những gì không hoạt động ..? – Psypher
Tôi mong rằng sau khi cuộn đến vị trí cuối cùng tôi sẽ thấy lần xem cuối cùng không bị cắt. Ngay bây giờ tôi chỉ nhìn thấy một phần của xem (có vẻ như nó không được cuộn xuống dưới cùng của xem cuối cùng - chỉ là một phần rất ít của xem có thể nhìn thấy). Nếu recycleview di chuyển ra khỏi CoordinatorLayout tất cả hoạt động chính xác - scrollToPosition hoạt động như tôi mong đợi - xem lần cuối có thể nhìn thấy mà không cần cắt bất kỳ thứ gì. Nhưng tôi hy vọng nó sẽ cùng một hành vi trong CoordinatorLayout quá – dmtrlbdv
xin lỗi, quên thêm. Tôi đang sử dụng LinearLayoutManager và com.android.support:design:22.2.0 – dmtrlbdv