---
title: "android走马灯效果"
author: "zhangle2612"
date: "2010-10-20T14:43:30Z"
tags: []
categories: ["移动开发"]
slug: "android"
draft: false
lastmod: "2010-10-20T14:43:30Z"
id: 789544
url: "https://lowry.iteye.com/blog/789544"
---

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent">
    
    <Button
        android:layout_width="150dip" 
        android:layout_height="wrap_content"
        android:text="@string/marquee_default"
        android:singleLine="true"
        android:ellipsize="marquee"/>
        
    <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
        android:layout_width="150dip" 
        android:layout_height="wrap_content"
        android:text="@string/marquee_forever"
        android:singleLine="true"
        android:ellipsize="marquee"
        android:marqueeRepeatLimit="marquee_forever"/>  
           
</LinearLayout>

上述配置文件中有三个Button，当任何一个Button获得焦点的时候都会出现走马灯的效果，
而其中marqueeRepeatLimit的设置决定了走马灯将会走几圈
第一个Button没有设置这个参数，则是默认的三圈，走过三遍之后，Button上的text就停止了
第二个Button设置了为1，则只会走一圈，就停止了
最后一个Button则会永远的是循环走马灯的效果。