0

I am trying to implement a android app. I have problems with TextView in a ScrollView. When I write some text into TextView according to its lenght some rows of the text at the top cannot be seen. I think they are occuluded with other things which resides in the top. Here is my xml file.

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/LinearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <RadioGroup android:id="@+id/RadioGroup1" android:layout_width="wrap_content" android:layout_height="wrap_content" > <RadioButton android:id="@+id/SayisalRadioButton" android:layout_width="158dp" android:layout_height="wrap_content" android:checked="true" android:text="@string/SayisalLoto" /> <RadioButton android:id="@+id/SuperLotoRadioButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/SuperLoto" /> </RadioGroup> <TableRow android:id="@+id/KolonSayisiTableRow" android:layout_width="wrap_content" android:layout_height="wrap_content" > <EditText android:id="@+id/KolonSayisiEditText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="@string/KolonSayisiHint" android:inputType="number" android:text="@string/Bos" > <requestFocus /> </EditText> <Button android:id="@+id/SallaButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/Uret" /> <ProgressBar android:id="@+id/SonucProgressBar" style="?android:attr/progressBarStyleHorizontal" android:layout_width="150dp" android:layout_height="wrap_content" android:visibility="invisible" /> </TableRow> <ScrollView android:id="@+id/SonucScrollView" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="center" > <TextView android:id="@+id/SonucTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:editable="false" android:scrollbarAlwaysDrawVerticalTrack="true" android:text="@string/Bos" android:textAppearance="?android:attr/textAppearanceMedium" /> </ScrollView> </LinearLayout> 

For Example when I put a text with multiple lines into the TextView with ID : SonucTextView according to its size I cannot see the some parts of the text at the top. How can I solve this problem? Is it related to the layout that I am using?

3 Answers 3

2

Your question is related to this one. So I suggest you check out the accepted answer.

That answer states that all you have to do is to set the maximum lines you want it to display and give it a scrollbar like so:

<TextView android:id="@+id/SonucTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:editable="false" android:text="@string/Bos" android:textAppearance="?android:attr/textAppearanceMedium" android:maxLines="5" android:scrollbars="vertical" /> 

And then proceed to setting the event in the code :

TexView.setMovementMethod(new ScrollingMovementMethod()) 

I'd like to add that the ScrollView widget is to be used when you want your entire view to scroll, not a single widget.

Hope this helps!

Sign up to request clarification or add additional context in comments.

7 Comments

Thank you for your answer. Then how can I scroll a single widget? Is there any way to scroll only some part of the display?
You pointed out that when I put the vertical scroll into the Textview then the problem goes am I right?
Did you check out the related question I've linked at the beginning of my answer, your problem is pretty much identical. Putting the vertical scroll isn't all there is to it, you have to add the piece of code.
Then should I remove the scrollview?
Yes, you will not need the ScrollView widget.
|
1

Try it:

<ScrollView android:id="@+id/SonucScrollView" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="center" > <TextView android:id="@+id/SonucTextView" android:layout_width="wrap_content" android:layout_height="match_parent" // or fixed size android:layout_gravity="center" android:editable="false" android:scrollbarAlwaysDrawVerticalTrack="true" android:text="@string/Bos" android:textAppearance="?android:attr/textAppearanceMedium" /> </ScrollView> 

If you got wrap_content you can't have size to scroll it.

1 Comment

When I put match_parent it says you should use wrap_content in there. The eclipse suggests that. And it is not a solution for this case.
0

Best Way

 <android.support.v4.widget.NestedScrollView android:id="@+id/scrollView1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/btmlyt" android:layout_below="@+id/deshead_tv"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TextView android:id="@+id/des_tv" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/btmlyt" android:background="@android:color/white" android:paddingLeft="3dp" android:paddingRight="3dp" android:scrollbars="vertical" android:paddingTop="3dp" android:text="description" android:textColor="@android:color/black" android:textSize="18sp" /> </LinearLayout> </android.support.v4.widget.NestedScrollView> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.