Android 微光闪烁效果之更强Shimmer-android

实现Android Shimmer效果的解决方案不少,在前一篇中介绍了facebook自家的Android Shimmer效果实现(《Android Shimmer微光闪烁shimmer-android》文章链接地址: http://blog.csdn.net/zhangphil/article/details/49722913  ),本文介绍另外一种我个人觉得比facebook更好的一种实现效果:Shimmer-android(我个人建议使用这个开源库实现Android Shimmer效果,可定制效果更强)
Shimmer-android在github上的项目主页是: https://github.com/RomainPiel/Shimmer-android  Android 微光闪烁效果之更强Shimmer-android_第1张图片
Shimmer-android干脆在Android TextView,Button的基础上重新写了ShimmerTextView和ShimmerButton。如果只是需要将一段文字实现Shimmer效果,直接使用ShimmerTextView即可。

Shimmer-android使用和前一篇facebook的使用类似,先写一个布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#9e9e9e" >

    <com.romainpiel.shimmer.ShimmerTextView
        android:id="@+id/shimmer_tv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:gravity="center"
        android:text="强哥手机演示"
        android:textColor="#757575"
        android:textSize="20sp" />

</RelativeLayout>


package com.example.test33;

import com.romainpiel.shimmer.Shimmer;
import com.romainpiel.shimmer.ShimmerTextView;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		  ShimmerTextView tv = (ShimmerTextView) findViewById(R.id.shimmer_tv);
	        Shimmer shimmer = new Shimmer();
	        shimmer.setDuration(3000);
	        shimmer.start(tv);
	}


}


你可能感兴趣的:(android)