[英]TextView text going out of bounds
我知道这个问题被问了很多,但我真的搜索了一个小时,仍然没有找到答案。 我的对话片段中的 TextView 超出了范围,就像里面的文本一样。
第一个 textview 应该说“Adakah anda.......”但它就这样越界了。 我尝试从换行更改为匹配父级,然后填充权重但仍然不会改变问题,自动调整库的大小(不是我想要的,我想调整 textview 的大小,而不是 textsize)。 请帮忙,tq。
下面是 XML 代码
<LinearLayout
android:layout_width = "match_parent"
android:orientation="horizontal"
android:padding="3dp"
android:layout_marginBottom="30dp"
android:layout_height = "match_parent">
<TextView
android:id = "@+id/tvAdakah"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:layout_weight = "1"
android:text = "@string/adakah_anda_menstruasi_pada_hari_ini" />
<Switch
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:layout_gravity="right|center"
android:layout_weight="1"
android:gravity="right|center"/>
</LinearLayout>
尝试使用以下,
android:scrollHorizontally="true"
android:ellipsize="end"
android:maxLines="1"
对于 textView,也许它可以提供帮助
您可以在一行中显示它并制作移动文本
像这样使用 xml 代码
<TextView
android:id = "@+id/tvAdakah"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:layout_weight = "1"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:text = "@string/adakah_anda_menstruasi_pada_hari_ini" />
在 java class 你需要设置选中这个 textView
TextView view = findViewById(R.id.tvAdakah);
view.setSelected(true);
希望它会有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.