Question

I am trying to put some triangles & squares on Android screen in certain way as shown in following figure. I am putting them separately because all shapes are clickable.

alt text

I used RelativeLayout (other layouts I tried, but they aren't working). Following is xml code for the same:

<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" />

Here I am trying only 3 triangles, 2 on the left-top corner and one on the left-bottom corner. Now whatever, I trial-error, somehow the bottom triangle never shows up. I end up as following: alt text Any one have idea, how to achieve it ? [P.S.: Strangely in the xml file, I am getting the same figure even removing following lines from both the ImageViews android:layout_alignLeft="true" android:layout_alignTop="true" ]

Was it helpful?

Solution

I have found one easier way to achieve this. I have drawn all the images separately in the same dimension width x height. e.g. If the overall image size is 400 x 300 then, I would draw all the triangles and diamonds individually at given points in the same 400 x 300 frame.

->following is triangle on top-left alt text

-> following is triangle on left-top alt text

-> following is diamond in left alt text

Also note that, everyone's background has been removed (by PAINT.net) so that they can overlap on each other (otherwise final image will be only visible). Now all images will be simply declared in FrameLayout with scaleType="fitXY". Done !!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top