Android 带有4个按钮的桌面布局的ImageView

Android 带有4个按钮的桌面布局的ImageView,android,android-layout,Android,Android Layout,我目前正在制作一个应用程序,我希望屏幕顶部有一个imageview(屏幕与顶部的间隙为10%),imageview下面有一个表,其中有4个按钮 我现在得到的是: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:

我目前正在制作一个应用程序,我希望屏幕顶部有一个imageview(屏幕与顶部的间隙为10%),imageview下面有一个表,其中有4个按钮

我现在得到的是:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/testhback"
android:gravity="bottom" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="@dimen/f1"
    android:adjustViewBounds="true"
    android:src="@drawable/img1" />

<TableLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="@dimen/top2"
    android:stretchColumns="*" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/button5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/button4"
            android:onClick="changepic2"
            android:text="Breaking Dawn" />

        <Button
            android:id="@+id/button4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/button1"
            android:layout_alignBottom="@+id/button1"
            android:layout_alignLeft="@+id/button5"
            android:layout_alignParentRight="true"
            android:onClick="changepic3"
            android:text="New Moon (2)" />
    </TableRow>

    <TableRow
        android:id="@+id/tableRow3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@+id/button3"
            android:layout_alignParentLeft="true"
            android:onClick="changepic"
            android:text="Twilight (1)" />

        <Button
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:onClick="changepic1"
            android:text="Eclipse (3)" />
    </TableRow>
</TableLayout>


问题是,我试图设置表格顶部的边距。但在每个屏幕上,它看起来都不一样,我不知道如何告诉它自动获取,比方说,它下面的顶行是10%,imageview是70%,对于底部有4个按钮的表格,为20%。

您可以使用具有垂直方向的线性布局,并配置布局权重属性以进行此排列

有关更多信息,请检查此处,如果问题仍然存在,请返回


希望这有帮助

必须使用android:layout\u width=0dp、android:weightSum和android:layout\u weight

那会帮你的