Shimmer-android在github上的项目主页是:https://github.com/RomainPiel/Shimmer-android
效果如图:
Shimmer-android使用
- <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 @ CSDN"
- android:textColor="#757575"
- android:textSize="20sp" />
- </RelativeLayout>
然后在Java代码中启动动画执行:
- import android.app.Activity;
- import android.os.Bundle;
- import com.romainpiel.shimmer.Shimmer;
- import com.romainpiel.shimmer.ShimmerTextView;
- 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(2500);
- shimmer.start(tv);
- }
- }
start执行,cancel停止。