GridView的错误水平间距 [英] GridView error in horizontal spacing
问题描述
我把一个GridView在我的XML布局文件。
I have placed a GridView in my XML layout file.
我在英语(LTR)希望它显示在这两个API 17-21
但是,当我巫语言为阿拉伯语(RTL)的horizontalSpacing是在API 17-19忽略,但在21 API,因为我想它显示出来。
It is displayed as I wanted in the English (LTR) on both API 17-21 But when I witch the language to Arabic (RTL) the horizontalSpacing is ignored on API 17-19 but on API 21 it is displayed as I wanted.
发生在模拟器和真正的Android设备上的相同的行为。
The same behavior occurred on emulators and real Android devices.
XML code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/services_home_main_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/services_home_contents"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_above="@+id/services_home_bottom_layout">
<GridView
android:id="@+id/services_home_services_gridview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="3"
android:horizontalSpacing="4dp"
android:verticalSpacing="4dp"
android:layout_margin="4dp"
android:gravity="center"
android:choiceMode="singleChoice" />
</LinearLayout>
<LinearLayout
android:id="@id/services_home_bottom_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
</RelativeLayout>
XML code的项目:
XML code for items:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/services_drawer_item_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:padding="4dp"
android:background="@color/Gray_CC"
android:drawableTop="@drawable/tall4"
android:text="@string/app_name" />
下面是我的阿拉伯语(RTL)界面的屏幕截图:
Here is my screenshots of Arabic (RTL) UI:
注意在第一张截图的水平间距
推荐答案
我有同样的问题,我试图解决它,但它只是没有按预期工作。如果您在清单有RTL设置,那么180设置GridView控件LRT和rotateY的布局方向。
I had the same problem and i tried to solve it but it just doesn't work as expected. If you have RTL set in your manifest then set the layout direction of the GridView to LRT and rotateY by 180.
下面是详细的解释:<一href=\"http://stackoverflow.com/questions/17830300/android-grid-view-place-items-from-right-to-left\">android从右侧网格视图放置物品到左
这篇关于GridView的错误水平间距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!