我期待实现一个类似于Windows 8 metro用户界面的布局,在一个较大的矩形顶部有2个小方形网格物品。我使用下面的代码是:Android正确的布局不可见
<?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="fill_parent"
android:background="#eeeeee"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#eeeeee" >
<GridView
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:layout_marginTop="5dp"
android:adjustViewBounds="true"
android:columnWidth="170dp"
android:drawSelectorOnTop="true"
android:gravity="center"
android:horizontalSpacing="2dp"
android:numColumns="2"
android:requiresFadingEdge="vertical"
android:stretchMode="spacingWidthUniform"
android:verticalSpacing="10dp" />
</RelativeLayout>
<ImageView
android:id="@+id/img1"
android:src="@drawable/aloha2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp" />
</LinearLayout>
但是,我只能查看前2个网格项目,但不能低于它的图像视图这样。
为什么没有被这里显示的矩形图像的看法? 我犯了什么错误?
谢谢
你不需要所有这些布局......只是一个GridLayout和3个孩子。教程:http://www.techotopia.com/index.php/Working_with_the_Android_GridLayout_in_XML_Layout_Resources –
在RelativeLayout中android:layout_height =“fill_parent”可能是原因。 – 0x5f3759df
@DerGolem,但不会使用gridlayout给我3方形图像?我在一个矩形的顶部寻找2个方格。 –