我正在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