-1

I have a TextView in Android that shows the information that it's retrieved from a database so I don't know how much lines will be used for show the information.

This is my TextView:

<TextView
    android:id="@+id/lblInfo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="10dp"
    android:inputType="textMultiLine"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textSize="15sp" />

And what I tried it's to put the property android:inputType="textMultiLine" but it gives to me an advice:

Attribute android:inputType should not be used with <TextView>: Change element type to <EditText>?

I searched on Internet but in all answers they know the maximum lines that they need, so they use the property android:maxLines="the maximum of lines they want" or android:lines="the total of lines that the TextView has" but I don't want that because I don't know how much lines I will have in my TextView.

How can I make a TextView with an undefined number of lines?

Thanks in advance!

Francisco Romero
  • 12,787
  • 22
  • 92
  • 167
  • 1
    TextView supports unlimited lines by default. Are you talking about how many lines are visible? – adelphus Aug 19 '15 at 11:30
  • 1
    this could help you http://stackoverflow.com/questions/6674578/multiline-textview-in-android – Sharjeel Aug 19 '15 at 11:32
  • @adelphus I suppose it is with putting the number of Lines, right? But you makes me open my eyes and know I got what I wanted. Thank you! – Francisco Romero Aug 19 '15 at 11:36
  • You have hard coded the margin in your textView, that could be the reason that it is not expanding according to the text entered, check if there is any view below your textview and you've hardcoded the margin of that view from this textView. – Vaishali Sharma Aug 19 '15 at 11:38
  • @VaishaliSharma Now I have what I wanted but, in your opinion, how should I put a margin? Thanks! – Francisco Romero Aug 19 '15 at 11:43
  • Why the downvote is? Is it something wrong on the question? – Francisco Romero Aug 19 '15 at 12:45

1 Answers1

0

Use following xml. Hopefully it will work.

<EditText 
...
android:inputType="textMultiLine"
/>