我已经看过了很多问题,但没有列出的解决方案解决了我的问题:Scrollview doesn't scroll to the margin at the bottomAndroid的滚动视图不滚动一路下跌
ScrollView doesn't scroll to the bottom
(Android) ScrollView won't scroll all the way to the bottom of my LinearLayout
我有一个应用程序在滚动视图中包含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
我曾尝试与滚动型的宽度和高度都match_parent和WRAP_CONTENT搞乱截图。我也在true和false之间切换fillViewPort。我为我的元素取下了所有填充物,仍然遇到同样的问题。
您是否尝试过用'wrap_content'设置'ScrollView'和'LinearLayout'的高度。为什么添加'toString()',我认为'Html.fromHtml()'工作正常。 –
我将ScrollView的高度和LinearLayout高度设置为wrap_content,但仍然遇到同样的问题。另外,我在Html.fromHtml()上调用toString(),因为响应包含某些单词上的标签,并因此而突出显示它们。我不希望发生这种情况。 –
我最终做了一个黑客,我用这种方式添加了一堆新行tvAbilities.setText(Html.fromHtml(abilities).toString()。concat(“\ n \ n \ n \ n”); 这是真的很难看,但我无法想出一种方法让它一直滚动到我的tvAbilities textview的最后几行。 –