我查看了很多问题,但列出的解决方案都没有解决我的问题:Scrollview 不会滚动到底部边缘 https://stackoverflow.com/questions/17124680/scrollview-doesnt-scroll-to-the-margin-at-the-bottom
ScrollView 不滚动到底部 https://stackoverflow.com/questions/15131962/scrollview-doesnt-scroll-to-the-bottom
(Android) ScrollView 不会一直滚动到 LinearLayout 的底部 https://stackoverflow.com/questions/17337628/android-scrollview-wont-scroll-all-the-way-to-the-bottom-of-my-linearlayout
我有一个具有以下布局的应用程序,其中包含 ScrollView 中的 LinearLayout
<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>
基本上,这个布局正在用于片段。在该片段中,我使用通过查询网站获得的字符串来调用 tvPowers 和 tvAbilities 的 settext。
这是一个片段
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;
}
这是我的滚动视图没有一直向下滚动的屏幕截图Picture https://i.stack.imgur.com/rCf3g.png
我尝试过将 ScrollView 的宽度和高度弄乱为 match_parent 和 wrap_content 。我还在 true 和 false 之间切换 fillViewPort。我去掉了元素的所有填充,但仍然遇到同样的问题。