Bookmark and Share

I have been working on Android lately so from now on, I will post some articles about Android besides Flash:)

Starting from the basic, how to make single line text with EditText component in layout XML.

The quickest way to do it is using “android:singleLine=true” attribute but it is deprecated so we need to use “android:inputType=none” instead:

1
2
3
4
5
<EditText 
	android:id="@+id/myText" 
	android:layout_width="fill_parent" 
	android:layout_height="wrap_content" 
	android:inputType="none" />

If your text is longer than current width, it will wrap to next line so you need to add “android:scrollHorizontally=true” too:

1
2
3
4
5
6
<EditText 
	android:id="@+id/myText" 
	android:layout_width="fill_parent" 
	android:layout_height="wrap_content" 
	android:inputType="none"
	android:scrollHorizontally="true" />

If you want to learn more about Android development, you can check out Android official developer site at http://developer.android.com.