Umieściłem GridView w moim pliku układu XML.Błąd GridView w odstępach poziomych
Jest wyświetlany tak, jak chciałem w języku angielskim (LTR) na obu interfejsach API 17-21 Ale kiedy używam języka na arabski (RTL), horizontalSpacing jest ignorowany w API 17-19, ale na API 21 jest wyświetlany tak jak chciałem.
To samo zachowanie wystąpiło na emulatorach i rzeczywistych urządzeniach z Androidem.
kod XML:
<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>
kod XML dla przedmiotów:
<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" />
Oto moje screeny arabski (RTL) Ui:
Wskazówka poziome odstępy w pierwszym zrzucie
To powinno działać dla GridView tylko z obrazem, ale jeśli jest też tekst, może on zostać odbity. Tak więc element Grid również musi zostać obrócony o 180. – darshanz
Właśnie ustawiłem kierunek na 'grid.setLayoutDirection (View.LAYOUT_DIRECTION_LTR)' i zadziałało. –