Jul 18, 2011

android:singleLine

android:singleLine attribute (either "true" or "false") constrains the text to a single horizontally scrolling line instead of letting it wrap onto multiple lines.

example:

Example of using android:singleLine

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TextView without singleLine\n - default text: abcdefghijklmnopqrstuvwxyz! "
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="TextView WITH singleLine\n - default text: abcdefghijklmnopqrstuvwxyz! "
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="EditText without singleLine\n - default text: abcdefghijklmnopqrstuvwxyz! "
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="EditText WITH singleLine\n - default text: abcdefghijklmnopqrstuvwxyz! "
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button without singleLine\n - default text: abcdefghijklmnopqrstuvwxyz! "
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="Button WITH singleLine\n - default text: abcdefghijklmnopqrstuvwxyz! "
/>
</LinearLayout>



Related Post:
- android.text.InputType

No comments:

Post a Comment

Infolinks In Text Ads