FaceBook微光闪烁---第三方开源--shimmer-android

Android上的微光闪烁shimmer效果,实现的手段不少,其中比较好的是facebook做的开源库:shimmer-android,其在github上的项目主页是:https://github.com/facebook/shimmer-android 另外一个链接:http://facebook.github.io/shimmer-android/ 其实指向的项目都是一个项目内容。
要使用facebook的Android Shimmer微光闪烁,需要先到其主页下载jar包,下载后直接放到自己Eclipse的项目libs里面。然后在布局文件中写一个com.facebook.shimmer.ShimmerFrameLayout布局,包裹自己的view.

比如一个TextView:

 1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 2     xmlns:tools="http://schemas.android.com/tools"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent"
 5     >
 6 
 7     <com.facebook.shimmer.ShimmerFrameLayout
 8         android:id="@+id/shimmer_view_container"
 9         android:layout_width="wrap_content"
10         android:layout_height="wrap_content"
11         android:layout_centerInParent="true" >
12 
13         <TextView
14             android:layout_width="wrap_content"
15             android:layout_height="wrap_content"
16             android:background="#ffc400"
17             android:padding="10dip"
18             android:text="android"
19             android:textColor="#eeeeee"
20             android:textSize="20sp" />
21     </com.facebook.shimmer.ShimmerFrameLayout>
22 
23 </RelativeLayout>
 1 package com.zzw.shimmer;
 2 
 3 import com.facebook.shimmer.ShimmerFrameLayout;
 4 
 5 import android.app.Activity;
 6 import android.os.Bundle;
 7 
 8 public class MainActivity extends Activity {
 9 
10     @Override
11     protected void onCreate(Bundle savedInstanceState) {
12         super.onCreate(savedInstanceState);
13         setContentView(R.layout.activity_main);
14 
15         ShimmerFrameLayout container = (ShimmerFrameLayout) findViewById(R.id.shimmer_view_container);
16         
17         //执行的时长
18         container.setDuration(2500);
19         
20         //开始执行效果
21         container.startShimmerAnimation();
22     }
23 }
原文地址:https://www.cnblogs.com/zzw1994/p/4970387.html