Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice to show big text data in an android view?

Tags:

android

In my information area of my app I want to show a brief description of my app. For that I need to create a view with a lot of text. What is the best practice for that ? Actually I created a Linear Layout with a Scrollview, in this i will add my text, which also should contain some variable values e.g. my app version. But I do not know if there are better ways to do that?

Here is my current approach:

 <LinearLayout
     android:id="@+id/information_content"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:layout_above="@id/bottom_footer"
     android:layout_below="@id/top_header"
     android:layout_marginLeft="@dimen/marginLeft"
     android:layout_alignParentRight="true"
     android:layout_weight="1"
     android:orientation="vertical" >

     <ScrollView
         android:id="@+id/scrollView1"
         android:layout_width="match_parent"
         android:layout_height="wrap_content" >

         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent" 
             android:orientation="vertical"
             >

             <EditText
                 android:id="@+id/info_text"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:ems="10"
                 android:inputType="textMultiLine"
                 android:text="Hallo das ist ein test!!!
                 dsf" />

         </LinearLayout>
     </ScrollView>

 </LinearLayout>

Any recommendations?

Thanks

like image 279
Al Phaba Avatar asked Jan 15 '13 10:01

Al Phaba


1 Answers

LinearLayouts serve no purpose when there is only one child View. When I wanted to show a lot of text, I used this XML:

<!-- Display the record details in a scrolling text view. -->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/[my drawable]"
    android:fillViewport="true"
    android:scrollbars="vertical" >

    <TextView
        android:id="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/defaultDetail" />

</ScrollView>
like image 184
Sparky Avatar answered Oct 23 '22 17:10

Sparky