Application's component adapt to resolution of screen

  • Replies:0
  • OpenNot stickiedUnanswered

Jan 25, 2013 3:50:43 PM via Website

Hi all,

I'am new on android developement and I have some problem with my new application.

I want to know how I can adapt my application's component to resolution of smartphone or tablet screen ? Because when I creat my XML page for a ) Galaxy s3 screen (4.7) and I start my application in a tablet, the organisation of my application's compo don't change... Is horrible ^^

My Code:
1<RelativeLayout xmlns:android="
2 xmlns:tools=""
3 android:layout_width="match_parent"
4 android:layout_height="match_parent"
5 tools:context=".MainActivity" >
6
7 <Button
8 android:id="@+id/button_ChooseTheme"
9 android:layout_width="wrap_content"
10 android:layout_height="wrap_content"
11 android:layout_alignParentTop="true"
12 android:layout_centerHorizontal="true"
13 android:layout_marginTop="50dp"
14 android:drawableLeft="@drawable/noimage50"
15 android:drawablePadding="10dp"
16 android:textAlignment="2"
17 android:textSize="@dimen/normal_text_size" />
18
19 <TextView
20 android:id="@+id/textView_ShowValueLib"
21 android:layout_width="wrap_content"
22 android:layout_height="wrap_content"
23 android:layout_below="@+id/button_ChooseTheme"
24 android:layout_centerHorizontal="true"
25 android:layout_marginTop="40dp"
26 android:text="@string/showValueLib"
27 android:textSize="@dimen/initul_text_size" />
28
29 <EditText
30 android:id="@+id/editText_ValueToConvert"
31 android:layout_width="wrap_content"
32 android:layout_height="wrap_content"
33 android:layout_alignTop="@+id/textView_ShowValueLib"
34 android:layout_below="@+id/textView_ShowValueLib"
35 android:layout_centerHorizontal="true"
36 android:layout_marginTop="30dp"
37 android:digits="0123456789.,"
38 android:ellipsize="start"
39 android:ems="10"
40 android:gravity="center"
41 android:inputType="numberDecimal"
42 android:maxLines="1" />
43
44 <Button
45 android:id="@+id/button_Init_Unit"
46 android:layout_width="wrap_content"
47 android:layout_height="wrap_content"
48 android:layout_alignBaseline="@+id/button_Final_Unit"
49 android:layout_alignBottom="@+id/button_Final_Unit"
50 android:layout_toLeftOf="@+id/textView_ShowResultLib"/>
51
52 <Button
53 android:id="@+id/button_Transfert"
54 android:background="@drawable/transfert"
55 android:layout_width="wrap_content"
56 android:layout_height="50dp"
57 android:padding="4dp"
58 android:layout_alignBaseline="@+id/button_Init_Unit"
59 android:layout_alignBottom="@+id/button_Final_Unit"
60 android:layout_centerHorizontal="true"
61 android:layout_marginLeft="10dp"
62 android:layout_marginRight="10dp"
63 android:layout_toLeftOf="@+id/button_Final_Unit"
64 android:layout_toRightOf="@+id/button_Init_Unit" />
65
66 <Button
67 android:id="@+id/button_Final_Unit"
68 android:layout_width="wrap_content"
69 android:layout_height="wrap_content"
70 android:layout_below="@+id/editText_ValueToConvert"
71 android:layout_marginTop="31dp"
72 android:layout_toRightOf="@+id/textView_ShowResultLib"/>
73
74
75 <TextView
76 android:id="@+id/textView_ShowResultLib"
77 android:layout_width="wrap_content"
78 android:layout_height="wrap_content"
79 android:layout_below="@+id/button_Transfert"
80 android:layout_centerHorizontal="true"
81 android:layout_marginTop="40dp"
82 android:text="@string/resultLib"
83 android:textSize="@dimen/initul_text_size" />
84
85 <TextView
86 android:id="@+id/textView_ShowResult"
87 android:layout_width="wrap_content"
88 android:layout_height="wrap_content"
89 android:layout_below="@+id/textView_ShowResultLib"
90 android:layout_centerHorizontal="true"
91 android:layout_marginTop="5dp"
92 android:text="0,0"
93 android:textSize="@dimen/result_text_size" />
94
95</RelativeLayout>