欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Android自定義View旋轉(zhuǎn)圓形圖片

    Android自定義View旋轉(zhuǎn)圓形圖片

    這篇文章主要為大家詳細介紹了Android自定義View旋轉(zhuǎn)圓形圖片,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-01-01
  • Android仿微信長按菜單效果

    Android仿微信長按菜單效果

    這篇文章主要為大家詳細介紹了Android仿微信長按菜單效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-12-12
  • Android實現(xiàn)簡單的下拉阻尼效應(yīng)示例代碼

    Android實現(xiàn)簡單的下拉阻尼效應(yīng)示例代碼

    下面小編就為大家分享一篇Android實現(xiàn)簡單的下拉阻尼效應(yīng)示例代碼,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-01-01
  • android實現(xiàn)切換日期左右無限滑動效果

    android實現(xiàn)切換日期左右無限滑動效果

    本篇內(nèi)容給大家分享了android開發(fā)時候?qū)崿F(xiàn)自定義的日期無限左右滑動效果以及控件使用的技巧。
    2017-11-11
  • 詳解Android中BroadCastReceiver組件

    詳解Android中BroadCastReceiver組件

    這篇文章主要為大家詳細介紹了Android中BroadCastReceiver組件,Broadcast Receiver是Android的五大組件之一,使用頻率也很高,用于異步接收廣播Intent,感興趣的小伙伴們可以參考一下
    2016-02-02
  • Android編程實現(xiàn)調(diào)用系統(tǒng)圖庫與裁剪圖片功能

    Android編程實現(xiàn)調(diào)用系統(tǒng)圖庫與裁剪圖片功能

    這篇文章主要介紹了Android編程實現(xiàn)調(diào)用系統(tǒng)圖庫與裁剪圖片功能,結(jié)合實例形式分析了Android針對圖形的旋轉(zhuǎn)與剪切等具體操作技巧,需要的朋友可以參考下
    2017-01-01
  • Android開發(fā)筆記之Android中數(shù)據(jù)的存儲方式(二)

    Android開發(fā)筆記之Android中數(shù)據(jù)的存儲方式(二)

    我們在實際開發(fā)中,有的時候需要儲存或者備份比較復(fù)雜的數(shù)據(jù)。這些數(shù)據(jù)的特點是,內(nèi)容多、結(jié)構(gòu)大,比如短信備份等,通過本文給大家介紹Android開發(fā)筆記之Android中數(shù)據(jù)的存儲方式(二),對android數(shù)據(jù)存儲方式相關(guān)知識感興趣的朋友一起學習吧
    2016-01-01
  • Android Intent傳遞大量數(shù)據(jù)出現(xiàn)問題解決

    Android Intent傳遞大量數(shù)據(jù)出現(xiàn)問題解決

    這篇文章主要為大家介紹了Android Intent傳遞大量數(shù)據(jù)出現(xiàn)問題解決,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-07-07
  • Android?studio實現(xiàn)單選按鈕

    Android?studio實現(xiàn)單選按鈕

    這篇文章主要為大家詳細介紹了Android?studio實現(xiàn)單選按鈕,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-05-05
  • Android基于wheelView實現(xiàn)自定義日期選擇器

    Android基于wheelView實現(xiàn)自定義日期選擇器

    這篇文章主要為大家詳細介紹了Android基于wheelView實現(xiàn)自定義日期選擇器,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-07-07

最新評論