Android 滚动视图不会一直向下滚动 [英] Android scroll view does not scroll all the way down

查看:40
本文介绍了Android 滚动视图不会一直向下滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我查看了很多问题,但列出的解决方案都没有解决我的问题:Scrollview 不会滚动到底部的边距

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 不会滚动到底部

(安卓)ScrollView 不会一直滚动到我的 LinearLayout 的底部

我有一个具有以下布局的应用程序,其中包含一个 ScrollView 中的 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>

基本上,此布局用于 Fragment.在该片段中,我为 tvPowers 和 tvAbility 调用 settext,并使用查询网站获得的字符串.

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.

这是一个片段

    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

我尝试将 ScrollView 的宽度和高度作为 match_parent 和 wrap_content.我还在 true 和 false 之间切换了 fillViewPort.我去掉了元素的所有填充,但仍然遇到同样的问题.

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.

推荐答案

我遇到了同样的问题,这个解决方案对我有用:

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

使用 NestedScrollView

查看对我有帮助的答案.

这篇关于Android 滚动视图不会一直向下滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆