0

I'm using the following XML layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <!--Multi Line TextView -->
    <TextView
        android:id="@+id/incomingmsg"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:autoLink="web"
        android:inputType="textMultiLine"
        android:minLines="5"
        android:scrollbars="vertical"
        android:singleLine="false"
        android:textIsSelectable="true" >
    </TextView>
    <!--Some more Views Here -->
</LinearLayout>

If the TextView has too much data, then the Views below are not appearing on the screen.I want the Views to be displayed immediately below the TextView based on the size of the text.

2 Answers 2

3

Use RelativeLayout :

   // scrollview is to scroll the layout even the Textview takes the full height of the device so that the view is visible under TextView. 
   //If your Textview doesn't take too much height, you don't need to use scrollview.
   <Scrollview>
   <RelativeLayout>
        <TextView>
        <View
           android:layout_width="match_parent"
           android:layout_height="4dip"
           android:layout_below="@id/textview"
           android:background="#7c7c7c" />
   </RelativeLayout>
  <Scrollview>
2
  • I have some buttons at the end of the TextView. So i guess if the text is too big, I will have to scroll down to see the buttons?
    – coderplus
    Oct 5, 2012 at 20:36
  • 1
    If you want to see those buttons always on screen then put the buttons outside the scrollview and set layout_alignParentBottom="true". And set the scrollview above those buttons layout_above="@id/buttons_layout". Then your butttons will always be visible
    – knvarma
    Oct 6, 2012 at 7:04
2

According to your XML, your views are set to be above the TextView (the multi-lined one), and not below the TextView?

Also, there is a max_height, and max_lines attribute you can add or set. This may help.

1
  • that is what I want to do :-) But the problem is how would I decide on the max_height and max_lines. These are dependent on the device height.
    – coderplus
    Oct 5, 2012 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.