FaceBook微光閃爍---第三方開源--shimmer-android,facebookandroidsdk

來源:互聯網
上載者:User

FaceBook微光閃爍---第三方開源--shimmer-android,facebookandroidsdk

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         <TextView14             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     @Override11     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 }

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.