8

含まれているレイアウト内のアイテムに関して、レイアウト内のアイテムを整列させる方法を見つけようとしています。

視覚的な表現は次のとおりです。 ここに画像の説明を入力

そして、ここに私が探しているサンプルコードがあります(明らかに機能しません):
Main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <include
        android:id="@+id/info"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        layout="@layout/info" />
    //This would be the dark grey box
    <RelativeLayout
        android:layout_below="@id/item1">
    </RelativeLayout>
</RelativeLayout>

included.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="50dp">
    <ImageView
        android:id="@+id/item1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:paddingLeft="100dp"/>
</RelativeLayout>



これを達成する最善の方法は、ダークグレーのボックスをコードに動的に配置することだと思いますが、どこから始めればよいかわかりません。どんな助けでも素晴らしいでしょう。

4

1 に答える 1

7

インクルードの下にこれを作成できますか?このようなもの (代わりに item1 use info):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <include
        android:id="@+id/info"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        layout="@layout/info" />
    //This would be the dark grey box
    <RelativeLayout
        android:layout_below="@id/info">
    </RelativeLayout>
</RelativeLayout>
于 2012-09-26T10:44:56.803 に答える