2010-11-28 8 views
1

次の図に示すように、Androidの画面上にいくつかの三角形&の四角形を特定の方法で配置しようとしています。すべての図形がクリック可能なので、私はそれらを別々に置いています。Android:RelativeLayout with xml

alt text

私は(私が試した他のレイアウトを、彼らは働いていない)RelativeLayoutを使用。続いて、同じのためのXMLコードです:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<ImageView 
    android:id="@+id/LeftTopTriangle" 
    android:src="@drawable/a_triangle_towards_right" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="true" 
    android:layout_alignTop="true" 
    android:clickable="true" /> 
<ImageView 
    android:id="@+id/TopLeftTriangle" 
    android:src="@drawable/a_triangle_towards_bottom" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="true" 
    android:layout_alignTop="true" 
    android:clickable="true" /> 
<ImageView 
    android:id="@+id/LeftBottomTriangle" 
    android:src="@drawable/a_triangle_towards_right" 
    android:layout_below="@id/LeftTopTriangle" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:clickable="true" /> 

ここ

私は左上隅と左下隅の1にだけ3の三角形、2をしようとしています。今は何でも、私は試行錯誤して、どうにかして三角形が決して現れない。 私は次のようになります: alt text どのようにそれを達成するためのアイデアを持っていますか? は[PS:layout_alignLeft =「true」を アンドロイド:不思議なxmlファイルで、私もImageViews アンドロイドの両方から次の行を削除し、同じ数字を取得していますlayout_alignTop =「真」]

答えて

0

私は1つを発見しましたこれを達成するための簡単な方法。 すべての画像を同じ寸法の幅x高さで別々に描いています。例: 全体の画像サイズが400×300ならば、同じ400×300のフレーム内の任意の点で、すべての三角形とダイヤモンドを個別に描画します。

- >以下の左上 alt text

上の三角形である - - >次は左上 alt text

には三角形である>、次のことにも注意してください alt text

を左にダイヤモンドでありますお互いに重なり合うように、誰の背景も(PAINT.netによって)削除されています(そうしないと、最終的な画像は表示のみになります)。 すべての画像はscaleType = "fitXY"のFrameLayoutで単純に宣言されます。 完了!