0

私は現在、画面の上部にイメージビュー (画面の上部から 10% のギャップがある) と、イメージビューの下に 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%、イメージビューに 70%、4 ボタンがあるテーブルに 20% とします。それを一番下に。

4

2 に答える 2

0

この配置を行うために、LinearLayoutを垂直方向で使用し、layout_weight属性を構成できます。

詳細については、こちらhttp://blog.stylingandroid.com/archives/297を確認し、問題が解決しない場合は戻ってきてください。

お役に立てれば!

于 2012-11-03T18:01:58.527 に答える
0

android:layout_width = 0dp、android:weightSumおよびandroid:layout_weightを使用する必要があります

そのスレッドはあなたを助けるはずです

于 2012-11-03T18:02:41.010 に答える