之外我希望我的TextView被允许在屏幕的水平(也禁用水平滚动条),像这样的:允许的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>
机器人:单线= textView上的“true”可能会诀窍 –
哦,是的,它确实!很简单的解决方案请将其张贴为答案。它也许可以帮助其他人在截断文本后显示“....”的追踪者btw。我如何阻止这种情况发生? – Dinuka
切断文本后,显示“....”。我如何阻止? – Dinuka