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); } }