我有一個recylcler視圖,但它似乎沒有實現setGravity方法。RecyclerView重力
我的列表是水平對齊的,但我需要它居中。我怎麼做?
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>
這是它的外觀,我需要它爲中心
謝謝你們
另一個重要的變化是將'android:layout_width'設置爲'wrap_content'。 – 2017-05-31 17:47:25
這會將一個'RecyclerView'放在它的父對象'RelativeLayout'中。但是這對Recycler的物品沒有影響,或者Recycler的寬度是'match_parent'。 – 2017-06-07 21:06:16
RecyclerView沒有'layout_center_horizon'這樣的屬性 – 2017-08-23 11:48:19