最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android實(shí)現(xiàn)下拉刷新的視圖和圖標(biāo)的旋轉(zhuǎn)

 更新時(shí)間:2017年03月05日 09:42:17   作者:熊,我-  
本篇文章主要介紹了Android實(shí)現(xiàn)下拉刷新的視圖和圖標(biāo)的旋轉(zhuǎn)的實(shí)例,具有很好的參考價(jià)值。下面跟著小編一起來看下吧

一、下拉才出現(xiàn)的視圖

pull_to_refresh_header.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pull_to_refresh_header"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#F3F3F3">
 <RelativeLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:paddingTop="23dp">
  <LinearLayout 
       android:id="@+id/pull_to_refresh_view"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:orientation="vertical"
   android:layout_centerHorizontal="true">
   <TextView
android:id="@+id/pull_to_refresh_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
android:text="@string/pull_to_refresh_text"
    android:textColor="#777777"
    android:textSize="16sp"/>
   <TextView
android:id="@+id/pull_to_refresh_update_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
android:text="@string/pull_to_refresh_update_text"
    android:textColor="#999999"
    android:textSize="14sp"/>
  </LinearLayout>
  <ProgressBar
android:id="@+id/pull_to_refresh_progress"
   android:layout_width="30dp"
   android:layout_height="30dp"
android:layout_toLeftOf="@id/pull_to_refresh_view"
   android:layout_marginRight="22dp"
   android:layout_marginTop="5dp"
   android:indeterminate="true"
android:indeterminateDrawable="@drawable/ic_loading_refresh"
   android:visibility="gone"/>
  <ImageView
   android:id="@+id/pull_to_refresh_image"
   android:layout_width="32dp"
   android:layout_height="32dp"
android:layout_toLeftOf="@id/pull_to_refresh_view"
   android:layout_marginRight="20dp"
   android:layout_marginTop="5dp"
   android:src="@drawable/ic_refresh_down"
   android:scaleType="centerInside"
android:contentDescription="@string/app_name"/>
 </RelativeLayout>
 <View
  android:layout_width="match_parent"
  android:layout_height="15dp"/>
</LinearLayout>

ic_loading_refresh.xml

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
 android:drawable="@drawable/ic_loading"
 android:fromDegrees="0"
 android:toDegrees="360"
 android:pivotX="50%"
 android:pivotY="50%" />

1、ProgressBar的indeterminate屬性,代表進(jìn)程的時(shí)間是否不確定。

2、黃色底的是Android Studio的提示。第一個(gè)提示的是,當(dāng)LinearLayout中的Text拓展得足夠長時(shí),會(huì)與ImageView重疊,實(shí)際效果是把ImageView給覆蓋了。第二個(gè)是,建議用toStartOf代替toLeftOf,用marginEnd代替marginRight等。原因和影響還沒完全搞懂。

二、圖標(biāo)旋轉(zhuǎn)的動(dòng)畫

private ImageView mPull_to_refresh_image;
private RotateAnimation mFlipAnimation;

...

  mFlipAnimation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
    RotateAnimation.RELATIVE_TO_SELF, 0.5f);
  mFlipAnimation.setInterpolator(new LinearInterpolator());
  mFlipAnimation.setDuration(250);
  mFlipAnimation.setFillAfter(true);

...
mPull_to_refresh_image.startAnimation(mFlipAnimation);

1、構(gòu)造方法:

public RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue,
   int pivotYType, float pivotYValue)

(1)toDegrees - fromDegrees < 0 就會(huì)是逆時(shí)針旋轉(zhuǎn),反之是順時(shí)針。這是我取不同值測試出來的。水平線右邊是0°,或者360°,左邊是180°,或者是-180°。

(2)pivotType是樞軸類型,也就是旋轉(zhuǎn)中心。RELATIVE_TO_SELF代表相對這個(gè)view本身。0.5f代表這個(gè)view一半大小的位置。

2、setInterpolator作用是設(shè)置速度器。LinearInterpolator是勻速加速器,也就是勻速播放動(dòng)畫。

3、setDuration作用是設(shè)置動(dòng)畫時(shí)長,以毫秒為單位。

4、setFillAfter作用是,當(dāng)參數(shù)為true時(shí),動(dòng)畫播放完后,view會(huì)維持在最終的狀態(tài)。而默認(rèn)值是false,也就是動(dòng)畫播放完后,view會(huì)恢復(fù)原來的狀態(tài)。

以上就是本文的全部內(nèi)容,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,同時(shí)也希望多多支持腳本之家!

相關(guān)文章

最新評論

永登县| 田东县| 石河子市| 庆阳市| 右玉县| 奉贤区| 闽侯县| 五大连池市| 和平县| 九江市| 平泉县| 玉溪市| 梁山县| 杭锦后旗| 井陉县| 伊宁县| 应城市| 洮南市| 筠连县| 芮城县| 昆明市| 进贤县| 张掖市| 垦利县| 安新县| 石首市| 平谷区| 德保县| 石河子市| 东乡县| 怀集县| 浑源县| 台东市| 文水县| 阿拉善盟| 光泽县| 南丹县| 郴州市| 汝阳县| 铜陵市| 江油市|