android – 允许TextView在屏幕之外

android – 允许TextView在屏幕之外,第1张

概述我想让TextView水平地从屏幕上移出(并且还禁用水平滚动条),例如: 但是,我现在使用的XML会使它自动适合父类,例如: 码: <RelativeLayout xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" xmln 我想让TextVIEw水平地从屏幕上移出(并且还禁用水平滚动条),例如:

但是,我现在使用的XML会使它自动适合父类,例如:

码:

<relativeLayout xmlns:tools="http://schemas.androID.com/tools"    xmlns:androID="http://schemas.androID.com/apk/res/androID"    xmlns:app="http://schemas.androID.com/apk/res-auto"    androID:ID="@+ID/parentlayout"    androID:layout_wIDth="match_parent"    androID:layout_height="match_parent"    androID:background="#fff">    <TextVIEw        androID:layout_margintop="30px"        androID:ID="@+ID/tab1"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:text="hello1"        androID:textcolor="#1089F9"        androID:textSize="40sp"        androID:layout_marginleft="20dp"        androID:layout_marginBottom="5dp"/>    <TextVIEw        androID:layout_margintop="30px"        androID:ID="@+ID/tab2"        androID:layout_toRightOf="@+ID/tab1"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:text="hello2"        androID:textcolor="#1089F9"        androID:textSize="40sp"        androID:layout_marginleft="50dp"        androID:layout_marginBottom="5dp"/>    <TextVIEw        androID:layout_margintop="30px"        androID:ID="@+ID/tab3"        androID:layout_toRightOf="@+ID/tab2"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:text="hello3"        androID:textcolor="#1089F9"        androID:textSize="40sp"        androID:layout_marginleft="50dp"        androID:layout_marginBottom="5dp"/></relativeLayout>

如何更改代码以获取第一张图像中显示的布局?如果它超出了父文本,只需切断textvIEw.

编辑:尝试过linearLayout.它也没用

<linearLayout xmlns:tools="http://schemas.androID.com/tools"    xmlns:androID="http://schemas.androID.com/apk/res/androID"    xmlns:app="http://schemas.androID.com/apk/res-auto"    androID:ID="@+ID/parentlayout"    androID:layout_wIDth="match_parent"    androID:layout_height="match_parent"    androID:background="#fff"    androID:orIEntation="horizontal">    <TextVIEw        androID:layout_margintop="30px"        androID:ID="@+ID/tab1"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:text="hello1"        androID:textcolor="#1089F9"        androID:textSize="40sp"        androID:layout_marginleft="20dp"        androID:layout_marginBottom="5dp"/>    <TextVIEw        androID:layout_margintop="30px"        androID:ID="@+ID/tab2"        androID:layout_toRightOf="@+ID/tab1"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:text="hello2"        androID:textcolor="#1089F9"        androID:textSize="40sp"        androID:layout_marginleft="50dp"        androID:layout_marginBottom="5dp"/>    <TextVIEw        androID:layout_margintop="30px"        androID:ID="@+ID/tab3"        androID:layout_toRightOf="@+ID/tab2"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:text="hello3"        androID:textcolor="#1089F9"        androID:textSize="40sp"        androID:layout_marginleft="50dp"        androID:layout_marginBottom="5dp"/></linearLayout>
解决方法 尝试在3 TextVIEw上使用This属性

androID:maxlines="1"

设置maxlines =“1”后,我得到了这个结果

总结

以上是内存溢出为你收集整理的android – 允许TextView在屏幕之外全部内容,希望文章能够帮你解决android – 允许TextView在屏幕之外所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1123541.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存