我正在Android Studio上製作遊戲,並且存在Grid View組件的問題。我無法將網格視圖內的項目居中對齊,如After圖像。我嘗試了幾種方法,如android:stretchMode
或android:layout_centerHorizontal
,但它沒有幫助。這裏是我的XML代碼:Gridview中的居中對齊項目
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@android:color/holo_orange_light"
android:layout_weight="8"
android:layout_gravity="center">
<GridView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10px"
android:id="@+id/gridAnswersChar"
android:numColumns="8"
android:gravity="center">
</GridView>
</RelativeLayout>
前:
後:
你有沒有找到解決方案? – FiXiT
我還不知道:( –
很想看到這個答案。面對同樣的問題。 – lostintranslation