gpt4 book ai didi

android - NestedScrollView里面的TextView被一条底线截断

转载 作者:行者123 更新时间:2023-12-05 00:17:02 26 4
gpt4 key购买 nike

我有一个 ViewPager 项目,它看起来像这样:

<android.support.v4.widget.NestedScrollView 
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:paddingLeft="@dimen/material_horizontal_margin"
android:paddingRight="@dimen/material_horizontal_margin"
xmlns:android="http://schemas.android.com/apk/res/android">

<TextView
android:id="@+id/group_footer_pager_item_info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left"/>

</android.support.v4.widget.NestedScrollView>

TextView 的文本可以很长,但它的长度真的无关紧要,因为在任何情况下,如果它足够大以供滚动 - 文本的最后一行根本不可见。

这可能是什么原因?

最佳答案

我阅读并尝试了 stackoverflow 上的所有内容,包括这些帖子:

Android: Last line of textview cut off [1]

Android Textview text cut off at bottom [2]

TextView in List is cut off [3]

除了 Rubin Yoo 的解决方案不准确但与 [1] 中的问题类似,其他解决方案均无效。虽然我当时没有看到它,并且可能不会尝试,因为情况完全不同,所以我继续搜索并找到了这个链接:

https://www.reddit.com/r/androiddev/comments/4c6ri4/long_text_in_a_nestedscrollview/

那是一个完美的打击。因此,按照规则的要求,这里是它的答案 fragment :

Put the textview inside a FrameLayout - @samyboy89

以及我同意的可能解释:

I think it's an issue with the scroll view being unable to correctly calculate the height that needs to scroll. With the frame layout, it just gets the height of the frame layout, which correctly figured out the height of the text view. - @Nintynien

所以工作布局是:

<?xml version="1.0" encoding="utf-8"?>

<android.support.v4.widget.NestedScrollView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:paddingLeft="@dimen/material_horizontal_margin"
android:paddingRight="@dimen/material_horizontal_margin"
xmlns:android="http://schemas.android.com/apk/res/android">

<!-- FrameLayout is needed for the correct TextView's height
calculation. As without it the last line would be cut off.-->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/group_footer_pager_item_info"
style="@style/RobotoRegular.Black.Big"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left"/>

</FrameLayout>
</android.support.v4.widget.NestedScrollView>

在这上面花了一个小时,所以我认为它可以帮助将来的人。

祝你有美好的一天!

关于android - NestedScrollView里面的TextView被一条底线截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49558583/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com