从右侧启动GridView Elements

Sar*_*ara 8 android gridview

我正在创建一个应用程序,我希望从右到左填充gridview"使用它从右到左语言",我试图使gridView引力设置为正确但它不起作用...我的gridview布局如下.

提前致谢

<RelativeLayout
    android:id="@+id/grid_layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+id/show_info"
    android:gravity="right" >

    <GridView
        android:id="@+id/channel_grid"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_centerHorizontal="true"
        android:columnWidth="90dp"
        android:gravity="right"
        android:horizontalSpacing="10dp"
        android:numColumns="auto_fit"
        android:stretchMode="columnWidth"
        android:verticalSpacing="10dp" >
    </GridView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

Jel*_*lle 5

我认为您最好的猜测是从GridView源复制代码并将测量/布局更改为从右到左使用.

更新:视图的布局方向仅在API级别17(4.2)中引入.如果你比较4.24.1中的 GridView.java ,你可以看到,例如在方法中makeRow(),layoutDirection从4.2开始考虑,所以这应该工作!

您是否尝试android:layoutDirection="rtl"在API级别17上执行代码?