0
Ich baue ein Layout, und ich möchte eine zentrierte (In der Mitte des Bildschirms) Gridview zwischen zwei relativen Layouts haben. Wie kann ich das machen?Wie kann ich eine Gridview zwischen zwei relativen Layouts platzieren?
Mein Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="0sp"
android:layout_weight="1"
android:background="#000000"
>
</RelativeLayout>
<GridView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
android:numColumns="1"
android:padding="5dp"
android:id="@+id/gvMenu"
android:layout_gravity="center_horizontal" />
<RelativeLayout
android:layout_width="fill_parent"
android:background="#fff"
android:layout_height="0sp"
android:layout_weight="1">
</RelativeLayout>
</LinearLayout>
Thank yout.
Sie ** konnte **. Aber * verschachtelte Layouts sind schlecht für Performances * (wenn du dich interessierst). Also, es ist besser, ein großes RelativeLayout zu haben, das all das Zeug enthält. –
Vielen Dank für den Hinweis, ich habe das gleiche getan, nur mit einem relativen Layout –
Was ist muuuuuuuuch besser. –