我需要在項目中使用帶網格線的3列網格視圖。所以,我有一個結果;如何設置響應式XML的3列網格線
這是注3的結果(5.7" 和版本 「4.4.2」); http://i.imgur.com/fkkKOWE.jpg
這是注5的結果(5.7" 和版本 「機器人M」); http://i.imgur.com/6JFlSdf.jpg
這裏我的代碼; fragment_homepage.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridView
android:id="@+id/GVHomepage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="3"
android:verticalSpacing="1dp"
android:horizontalSpacing="1dp"
android:background="#edf2f8" />
<ProgressBar
android:id="@+id/PBLoading"
style="?android:attr/progressBarStyleInverse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</LinearLayout>
categories_row.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<RelativeLayout
android:layout_width="120dp"
android:layout_height="120dp"
android:background="#fff">
<TextView
android:id="@+id/TVCategoryName"
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Yiyecek"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="#745f87"
android:layout_centerHorizontal="true"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="@+id/IVCategoryPhoto"
android:layout_width="70dp"
android:layout_height="70dp"
android:scaleType="fitCenter"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:layout_below="@+id/TVCategoryName"
android:src="@mipmap/ic_launcher"/>
</RelativeLayout>
</LinearLayout>
那麼,如何獲得像 「注3」 的結果,在所有的屏幕分辨率?
檢查我發佈的代碼。它會爲你工作。 –