API Demos 2.3 学习笔记 (6)
更多精彩内容,请点击阅读: 《API Demos 2.3 学习笔记》 在TextView及其子类控件中,当文本内容太长,超过控件长度时,默认情况下,无法完全显示文本内容。此时,通过在xml布局文件中设置控件的android:ellipsize属性,可以将无法显示的部分用省略号表示,
更多精彩内容,请点击阅读:《API Demos 2.3 学习笔记》
1、默认不处理
android:singleLine="true" android:ellipsize="none"
2、省略号放在起始
android:singleLine="true" android:ellipsize="start"
3、省略号放在中间
android:singleLine="true" android:ellipsize="middle"
4、省略号放在结束
android:singleLine="true" android:ellipsize="end"
5、跑马灯效果
android:focusable="true" android:focusableInTouchMode="true" android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever"
注:1、android:singleLine="true"表示单行显示。
2、在设置跑马灯效果时候,最好加上android:focusable="true"和android:focusableInTouchMode="true",分别表示可以获得焦点,和在触摸模式下可以获得焦点。
3、android:marqueeRepeatLimit表示跑马灯效果重复显示的次数,只能取值marquee_forever和正整数。取值marquee_forever时,表示跑马灯效果一直重复显示。
下面我们进行实例代码解析:
res-value-string.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="marquee_default">This use the default marquee animation limit of 3</string> <string name="marquee_once">This will run the marquee animation once</string> <string name="marquee_forever">This will run the marquee animation forever</string> </resources>
res-layout-marquee.xml
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- 默认跑马灯效果 --> <button android:layout_width="150dip" android:layout_height="wrap_content" android:text="@string/marquee_default" android:singleline="true" android:ellipsize="marquee"></button> <!-- 跑马灯效果,重复播放一次 --> <button android:layout_width="150dip" android:layout_height="wrap_content" android:text="@string/marquee_once" android:singleline="true" android:ellipsize="marquee" android:marqueerepeatlimit="1"></button> <!-- 跑马灯效果,一直重复播放 --> <button android:layout_width="150dip" android:layout_height="wrap_content" android:text="@string/marquee_forever" android:singleline="true" android:ellipsize="marquee" android:marqueerepeatlimit="marquee_forever"></button> </linearlayout>
src-com.example.android.apis.text-Marquee.java
package com.example.android.apis.text; import com.example.android.apis.R; import android.app.Activity; import android.os.Bundle; public class Marquee extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //将marquee布局文件渲染出一个View对象,并作为Activity的默认View setContentView(R.layout.marquee); } }
效果预览:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to delete Xiaohongshu notes? Notes can be edited in the Xiaohongshu APP. Most users don’t know how to delete Xiaohongshu notes. Next, the editor brings users pictures and texts on how to delete Xiaohongshu notes. Tutorial, interested users come and take a look! Xiaohongshu usage tutorial How to delete Xiaohongshu notes 1. First open the Xiaohongshu APP and enter the main page, select [Me] in the lower right corner to enter the special area; 2. Then in the My area, click on the note page shown in the picture below , select the note you want to delete; 3. Enter the note page, click [three dots] in the upper right corner; 4. Finally, the function bar will expand at the bottom, click [Delete] to complete.

As a Xiaohongshu user, we have all encountered the situation where published notes suddenly disappeared, which is undoubtedly confusing and worrying. In this case, what should we do? This article will focus on the topic of "What to do if the notes published by Xiaohongshu are missing" and give you a detailed answer. 1. What should I do if the notes published by Xiaohongshu are missing? First, don't panic. If you find that your notes are missing, staying calm is key and don't panic. This may be caused by platform system failure or operational errors. Checking release records is easy. Just open the Xiaohongshu App and click "Me" → "Publish" → "All Publications" to view your own publishing records. Here you can easily find previously published notes. 3.Repost. If found

How to change the page that opens the Microsoft Edge browser to 360 navigation? It is actually very simple, so now I will share with you the method of changing the page that opens the Microsoft Edge browser to 360 navigation. Friends in need can take a look. I hope Can help everyone. Open the Microsoft Edge browser. We see a page like the one below. Click the three-dot icon in the upper right corner. Click "Settings." Click "On startup" in the left column of the settings page. Click on the three points shown in the picture in the right column (do not click "Open New Tab"), then click Edit and change the URL to "0" (or other meaningless numbers). Then click "Save". Next, select "

How to add product links in notes in Xiaohongshu? In the Xiaohongshu app, users can not only browse various contents but also shop, so there is a lot of content about shopping recommendations and good product sharing in this app. If If you are an expert on this app, you can also share some shopping experiences, find merchants for cooperation, add links in notes, etc. Many people are willing to use this app for shopping, because it is not only convenient, but also has many Experts will make some recommendations. You can browse interesting content and see if there are any clothing products that suit you. Let’s take a look at how to add product links to notes! How to add product links to Xiaohongshu Notes Open the app on the desktop of your mobile phone. Click on the app homepage

CheatEngine is a game editor that can edit and modify the game's memory. However, its default language is non-Chinese, which is inconvenient for many friends. So how to set Chinese in CheatEngine? Today, the editor will give you a detailed introduction to how to set up Chinese in CheatEngine. I hope it can help you. Setting method one: 1. Double-click to open the software and click "edit" in the upper left corner. 2. Then click “settings” in the option list below. 3. In the opened window interface, click "languages" in the left column

When editing text content in Word, you sometimes need to enter formula symbols. Some guys don’t know how to input the root number in Word, so Xiaomian asked me to share with my friends a tutorial on how to input the root number in Word. Hope it helps my friends. First, open the Word software on your computer, then open the file you want to edit, and move the cursor to the location where you need to insert the root sign, refer to the picture example below. 2. Select [Insert], and then select [Formula] in the symbol. As shown in the red circle in the picture below: 3. Then select [Insert New Formula] below. As shown in the red circle in the picture below: 4. Select [Radical Formula], and then select the appropriate root sign. As shown in the red circle in the picture below:

Title: How to deal with Laravel API error problems, specific code examples are needed. When developing Laravel, API errors are often encountered. These errors may come from various reasons such as program code logic errors, database query problems, or external API request failures. How to handle these error reports is a key issue. This article will use specific code examples to demonstrate how to effectively handle Laravel API error reports. 1. Error handling in Laravel

Oracle is a world-renowned database management system provider, and its API (Application Programming Interface) is a powerful tool that helps developers easily interact and integrate with Oracle databases. In this article, we will delve into the Oracle API usage guide, show readers how to utilize data interface technology during the development process, and provide specific code examples. 1.Oracle
