Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 9th, 2012  |  syntax: None  |  size: 2.06 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to correctly position android layout without using Absolute Layout?
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:tools="http://schemas.android.com/tools"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:background="@drawable/background"
  7. android:padding="20dp" >
  8.  
  9. <ImageView
  10.     android:id="@+id/imageView1"
  11.     android:layout_width="wrap_content"
  12.     android:layout_height="wrap_content"
  13.     android:layout_alignParentTop="true"
  14.     android:layout_centerHorizontal="true"
  15.     android:layout_marginBottom="50dp"
  16.     android:contentDescription="@string/application_logo_description"
  17.     android:src="@drawable/mylight" />
  18.  
  19. <ImageButton
  20.     android:id="@+id/settings_button"
  21.     android:layout_width="wrap_content"
  22.     android:layout_height="wrap_content"
  23.     android:layout_alignParentRight="true"
  24.     android:layout_alignParentTop="true"
  25.     android:background="@null"
  26.     android:contentDescription="@string/settings_button_description"
  27.     android:src="@drawable/settings_button" />
  28.  
  29. <ImageButton
  30.     android:id="@+id/flashlight_button"
  31.     android:layout_width="wrap_content"
  32.     android:layout_height="wrap_content"
  33.     android:layout_below="@+id/imageView1"
  34.     android:layout_centerHorizontal="true"
  35.     android:background="@null"
  36.     android:contentDescription="@string/flashlight_button_description"
  37.     android:src="@drawable/flashlight_button_selector" />
  38.  
  39. <ImageView
  40.     android:id="@+id/imageView2"
  41.     android:layout_width="wrap_content"
  42.     android:layout_height="wrap_content"
  43.     android:layout_above="@+id/ad_button"
  44.     android:layout_centerHorizontal="true"
  45.     android:contentDescription="@string/powered_by_description"
  46.     android:src="@drawable/powered_by" />
  47.  
  48. <ImageButton
  49.     android:id="@+id/ad_button"
  50.     android:layout_width="wrap_content"
  51.     android:layout_height="wrap_content"
  52.     android:layout_alignParentBottom="true"
  53.     android:layout_centerHorizontal="true"
  54.     android:background="@null"
  55.     android:contentDescription="@string/ad_button_description"
  56.     android:src="@drawable/freeml" />