最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

TextView實現(xiàn)跑馬燈效果 就這么簡單!

 更新時間:2017年08月04日 15:05:43   作者:飯飯_fan  
TextView實現(xiàn)跑馬燈效果,就這么簡單輕松實現(xiàn),這篇文章介紹了TextView制作跑馬燈效果的方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下

一、方法

這里我們用兩種方法來實現(xiàn)跑馬燈效果,雖然實質(zhì)上是一種

實質(zhì)就是:

1、TextView調(diào)出跑馬燈效果

2、TextView獲取焦點 

第一種:

1、TextView調(diào)出跑馬燈效果

android:ellipsize="marquee"

2、TextView獲取焦點

android:focusable="true"
android:focusableInTouchMode="true"

說明:

這種方法如果界面上別的控件獲取焦點的時候就會停止這個跑馬燈效果 

第二種:

1、TextView調(diào)出跑馬燈效果

android:ellipsize="marquee"

2、TextView獲取焦點

public class MyTextView extends TextView{ 

  public boolean isFocused() {
    return true;
  }

}

我們的TextView用的就是fry.MyTextView

說明:

就算別的程序獲取焦點,這個跑馬燈效果也不會停止。 

二、代碼實例

效果圖

三、代碼

fry.MyTextView

package com.example.textviewdemo;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;

public class MyTextView extends TextView{

 public MyTextView(Context context, AttributeSet attrs, int defStyle) {
 super(context, attrs, defStyle);
 // TODO Auto-generated constructor stub
 }

 public MyTextView(Context context, AttributeSet attrs) {
 super(context, attrs);
 // TODO Auto-generated constructor stub
 }

 public MyTextView(Context context) {
 super(context);
 // TODO Auto-generated constructor stub
 }
 
 @Override
 public boolean isFocused() {
 return true;
 }
}

/textViewDemo1/res/layout/activity04.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:orientation="vertical" >
 <TextView 
 android:id="@+id/tv_runHorseLamp"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:singleLine="true"
 android:ellipsize="marquee"
 android:focusable="true"
 android:focusableInTouchMode="true"
 android:text="這是一段很長的威武霸氣的滾動的實現(xiàn)跑馬燈效果的一段逼格很高的很有含義和涵養(yǎng)的文字"
 />
 <!--ellipsize是小數(shù)點的意思 marquee 這句話是添加滾動效果-->
 <!-- 獲取焦點之后才能滾動 -->

 <fry.MyTextView
 android:id="@+id/tv_runHorseLamp1"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:ellipsize="marquee"
 android:singleLine="true"
 android:text="這是一段很長的威武霸氣的滾動的實現(xiàn)跑馬燈效果的一段逼格很高的很有含義和涵養(yǎng)的文字"
 />


 <EditText
 android:id="@+id/et_1"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 >
 </EditText>
 
</LinearLayout>

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

最新評論

封开县| 昌图县| 五原县| 葵青区| 江门市| 中西区| 宾川县| 许昌市| 和田县| 孙吴县| 夏邑县| 长顺县| 玛曲县| 吴忠市| 深圳市| 精河县| 永年县| 金溪县| 昆明市| 大邑县| 龙州县| 潮州市| 自贡市| 宁阳县| 新源县| 龙州县| 上饶市| 吕梁市| 岫岩| 临西县| 林西县| 西乡县| 南和县| 阆中市| 通化县| 德钦县| 阿巴嘎旗| 西丰县| 潼南县| 玛纳斯县| 长沙县|