Tôi có chế độ xem recylcler, nhưng có vẻ như không thực hiện phương pháp setGravity.Lực hấp dẫn của RecyclerView
Danh sách của tôi được căn chỉnh theo chiều ngang, nhưng tôi cần nó được căn giữa. Làm thế nào để làm điều đó?
fragment_my_zone_item_controlled.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="match_parent"
android:background="@color/dark_grey">
<FrameLayout
android:id="@+id/fragment_my_zone_item_controlled_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/fragment_my_zone_item_controlled_tabs"
android:layout_marginBottom="12dp"
android:layout_marginTop="12dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/fragment_my_zone_item_controlled_tabs"
android:layout_width="match_parent"
android:layout_height="44dp"
android:background="@color/action_bar_color"
android:scrollbars="none" />
</RelativeLayout>
Đây là cách hiển thị, tôi cần nó để được tập trung
Cảm ơn các bạn
Thay đổi quan trọng khác là đặt 'android: layout_width' thành' wrap_content'. –
Điều này sẽ tập trung một 'RecyclerView' trong cha mẹ của nó -' RelativeLayout'. Nhưng điều này sẽ không ảnh hưởng đến các mục của Recycler hoặc khi chiều rộng của Recycler là 'match_parent'. –
RecyclerView không có thuộc tính như 'layout_center_horizon' –