2012-09-26 7 views
8

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

は視覚的な表現です:
enter image description herelayout_below item within includedレイアウト

そして、ここで私は(明らかに動作しません)を探していますサンプルコードです:
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> 



私はこれを実現する最良の方法は、動的にコード内の濃い灰色のボックスを配置してなりと仮定しているが、私はどこから始めれば見当がつかない。どんな助けも素晴らしいだろう。

+0

あなたはあなたが望むものを行うことはできません。私の考え方からすれば、それはしたくないでしょう。その余分なウィンドウをコードに追加してみてください。 – Luksprog

+0

このソリューションは私のために働いたhttps://stackoverflow.com/a/45450305/563735 –

+0

このソリューションは私のために働いたので。 https://stackoverflow.com/a/45450305/563735 –

答えて

7

これをあなたのインクルード以下にすることはできますか?このようなもの(代わりにitem1の使用情報):

<?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> 
+0

私はそう思います。もともと私は、暗い灰色のボックスポイントから、含まれているレイアウト内の要素までの矢印を持つことを望んでいました。もし私があなたの提案を受け入れるならば、私は矢を外さなければならないでしょう。それはそれがボックスと合っていることを示唆しています。私は実際にはそれを含むレイアウト内の何かに整列させる方法を探しています。含まれている要素の中にはいくつかの項目があり、クリックされた項目に "ポップアップ"を合わせたいと思います。私は何を達成しようとしているのかを明確にするためにイメージを更新しました。 – Rawr

+0

私はこの方向に進むことを決めたと思うので、私はこの答えを受け入れています:) – Rawr