Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android scroll view does not scroll all the way down

I have looked at many questions, but none of the solutions listed solved my problems: Scrollview doesn't scroll to the margin at the bottom

ScrollView doesn't scroll to the bottom

(Android) ScrollView won't scroll all the way to the bottom of my LinearLayout

I have an app with the following layout that contains a LinearLayout within a ScrollView

<ScrollView android:id="@+id/Scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
xmlns:android="http://schemas.android.com/apk/res/android">

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

    <TextView
        android:padding="8dp"
        android:id="@+id/tvPowersLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Powers"
        android:textSize="20dp"
        android:textStyle="bold"
        />
    <TextView
        android:padding="8dp"
        android:id="@+id/tvPowers"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="12dp"
        android:text="Placeholder for powers"
        />

    <TextView
        android:padding="8dp"
        android:textSize="20dp"
        android:textStyle="bold"
        android:text="Abilities"
        android:id="@+id/tvAbilitiesLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />

    <TextView
        android:padding="8dp"
        android:id="@+id/tvAbilities"
        android:layout_width="wrap_content"
        android:text="placeholder for abilities"
        android:layout_height="wrap_content"
        android:textSize="12dp"
        />

</LinearLayout>
</ScrollView>

Basically, this layout is is being used for a Fragment. Inside that fragment, I call settext for tvPowers and tvAbilities, with Strings I get from querying a website.

Here is a snippet

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scrollview,container,false);;

    TextView tvPowers = (TextView) view.findViewById(R.id.tvPowers);
    TextView tvAbilities = (TextView) view.findViewById(R.id.tvAbilities);


    tvPowers.setText(Html.fromHtml(powers).toString());
    tvAbilities.setText(Html.fromHtml(abilities).toString());

    return view;
}

Here is a screenshot of my scroll view not scrolling down all the way Picture

I have tried messing with ScrollView's width and height as both match_parent and wrap_content. I have also toggled fillViewPort between true and false. I took off all the padding for my elements and still get the same problem.

like image 456
Crazy_K Avatar asked Aug 12 '16 04:08

Crazy_K


1 Answers

I had the same problem and this solution worked for me:

Instead of ScrollView use NestedScrollView

Check the answer that helped me.

like image 188
Epanemu Avatar answered Nov 14 '22 23:11

Epanemu