gpt4 book ai didi

android - 如何让溢出的 TextView 与 android :ellipsize ="start"? 一起使用

转载 作者:行者123 更新时间:2023-11-29 21:04:56 24 4
gpt4 key购买 nike

在我的应用程序中,我经常在以下布局中动态更新 TextView 的内容:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container_view"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="@dimen/top_padding"
android:paddingRight="@dimen/side_padding"
android:paddingBottom="@dimen/top_padding"
android:paddingLeft="@dimen/side_padding">

<TextView
android:id="@+id/breadcrumbs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/title_showcase"
style="@style/ShowcaseBreadcrumbs"
android:ellipsize="start"
android:singleLine="true" />

<it.sephiroth.android.library.widget.HListView
android:id="@+id/item_carousel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_marginTop="-40dp"
android:listSelector="@android:color/transparent"
app:hlv_dividerWidth="10dp"
/>

</LinearLayout>

LinearLayout中的padding都是70dpHListViewHorizontalVariableListView .这是样式,尽管我怀疑它是否有用:

<style name="ShowcaseBreadcrumbs">
<item name="android:textSize">32sp</item>
<item name="android:background">@drawable/bottom_border_thin</item>
<item name="android:textColor">@color/white</item>
<item name="android:layout_marginBottom">10dp</item>
</style>

我用基本的 TextView.setText(String) 更新了 TextView 的内容。不幸的是,当文本变得足够长时,TextView 不会省略任何内容,因为溢出的文本刚从屏幕上消失:

enter image description here

我如何强制 TextView 显示其内容的末尾并在开头适本地设置椭圆?

最佳答案

显然,我遇到了 Android 的省略号功能和辅助功能服务的错误。感谢recent bug post在 Android 错误跟踪器上,我发现 LastPass 辅助功能服务(扫描应用程序以查找潜在的用户名/密码框以自动填充的服务)正在将 TextView 的内容跳回到开头。关闭 LastPass 服务解决了这个问题。

查看我拍摄的这个屏幕录像(注意按钮上方的 TextView):https://www.youtube.com/watch?v=7VoEfx0rgys

我还使用 Talkback 服务对其进行了测试 - 当服务开启时,TextView 再次跳转,就像视频中一样。关闭服务并重新启动应用程序产生了预期的效果。

请注意,我不必更改 XML 中的任何内容 - 将服务切换为关闭足以解决问题。

关于android - 如何让溢出的 TextView 与 android :ellipsize ="start"? 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24856471/

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