Monday, January 14, 2008

Resize Android EditText in XML


Someday, we want to set size Android Component in our application. We have many ways to set and reset the size of component. In this example we deal with Android EditText.

The Size of Component in Android can be set in XML with providing property android:layout_width and android:layout_height with a value followed by unit. For example we want to set EditText with 200sp width and 24sp height, the declaration is as follow:

<EditText id="@+id/Text1"
android:layout_width="200sp"
android:layout_height="24sp"
android:text="Text1"
android:singleLine="True"
/>

For detail information on unit like "sp", "pt", you can browse at Android Documentation or in topic Creating User Interface

Ok, Good Luck!

0 comments: