最新国产好看的视频,伊人天堂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à)值。下面跟著小編一起來(lái)看下吧

一、下拉才出現(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拓展得足夠長(zhǎng)時(shí),會(huì)與ImageView重疊,實(shí)際效果是把ImageView給覆蓋了。第二個(gè)是,建議用toStartOf代替toLeftOf,用marginEnd代替marginRight等。原因和影響還沒(méi)完全搞懂。

二、圖標(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í)針。這是我取不同值測(cè)試出來(lái)的。水平線右邊是0°,或者360°,左邊是180°,或者是-180°。

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

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

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

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

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

相關(guān)文章

最新評(píng)論

孟州市| 南城县| 凌海市| 明星| 丰原市| 嵩明县| 五常市| 马鞍山市| 陆良县| 措美县| 汾阳市| 霍州市| 定州市| 宁河县| 新河县| 巩留县| 武邑县| 斗六市| 林州市| 嘉祥县| 平顺县| 靖远县| 九龙坡区| 汨罗市| 射阳县| 广西| 苍山县| 通河县| 简阳市| 侯马市| 江陵县| 南华县| 安化县| 康保县| 泰安市| 冕宁县| 尚志市| 资兴市| 玛多县| 泽州县| 南京市|