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.
I used RelativeLayout (other layou开发者_开发技巧ts 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:
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
-> following is triangle on left-top
-> following is diamond in left
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 !!
精彩评论