<?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" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.prize.mydemo1.Main4Activity"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <!--TextView put picture example --> <!--android:drawableTop="@drawable/icon1" Put a picture on top of the text--> <!--android:drawablePadding="20dp" Set the space between the picture and the text --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Study hard" android:textColor="#0000ff" android:textSize="50sp" android:drawableTop="@drawable/icon1" android:drawablePadding="20dp" /> <!--The text is too long to be omitted. . . Example --> <!--android:maxLines="1" Set the number of TextView lines --> <!--android:ellipsize="end" Sets the end of text display. . . --> <!--android:layout_marginBottom="5dp" Set the layout spacing --> <TextView android:layout_width="200dp" android:layout_height="wrap_content" android:text="@string/main4Text1" android:maxLines="1" android:ellipsize="end" android:layout_marginBottom="5dp"/> <!--android:ellipsize="end" Sets the display ellipsis in the middle of the text. . . --> <TextView android:layout_width="200dp" android:layout_height="wrap_content" android:text="@string/main4Text1" android:maxLines="1" android:ellipsize="middle"/> <!--Set the text display with scrolling effect--> <!--android:singleLine="true" set a single line --> <!--android:marqueeRepeatLimit="marquee_forever" Set the number of scrolls, here is the permanent scroll --> <!--android:ellipsize="marquee" ellipsize means omitting the position, and marquee means scrolling mode --> <!--android:focusable="true" means focusable and selected. Only focused text will scroll --> <!--android:focusableInTouchMode="true" Focusable touch mode --> <!--Note that this method sets text scrolling, only a piece of text on a page can be focused and scrolled by default --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/main4Text1" android:layout_marginTop="30dp" android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:focusable="true" android:focusableInTouchMode="true"/> </LinearLayout> </LinearLayout>
running result: