成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

Android應(yīng)用中怎么實(shí)現(xiàn)一個(gè)下拉刷新功能-創(chuàng)新互聯(lián)

Android應(yīng)用中怎么實(shí)現(xiàn)一個(gè)下拉刷新功能?針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。

成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè),成都做網(wǎng)站公司-成都創(chuàng)新互聯(lián)已向數(shù)千家企業(yè)提供了,網(wǎng)站設(shè)計(jì),網(wǎng)站制作,網(wǎng)絡(luò)營(yíng)銷等服務(wù)!設(shè)計(jì)與技術(shù)結(jié)合,多年網(wǎng)站推廣經(jīng)驗(yàn),合理的價(jià)格為您打造企業(yè)品質(zhì)網(wǎng)站。

一、下拉才出現(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)畫(huà)

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)畫(huà)。

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

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

關(guān)于Android應(yīng)用中怎么實(shí)現(xiàn)一個(gè)下拉刷新功能問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒(méi)有解開(kāi),可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識(shí)。

當(dāng)前名稱:Android應(yīng)用中怎么實(shí)現(xiàn)一個(gè)下拉刷新功能-創(chuàng)新互聯(lián)
URL標(biāo)題:http://jinyejixie.com/article6/djssog.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站網(wǎng)站建設(shè)、ChatGPT、小程序開(kāi)發(fā)、微信公眾號(hào)、網(wǎng)頁(yè)設(shè)計(jì)公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)
泰顺县| 抚顺县| 德保县| 兖州市| 龙岩市| 始兴县| 从江县| 南江县| 双流县| 齐河县| 佛学| 鄂州市| 鄂州市| 阜平县| 霍林郭勒市| 高碑店市| 伊宁市| 拜泉县| 肃北| 广昌县| 炉霍县| 合肥市| 遂川县| 天全县| 元江| 连南| 左权县| 高尔夫| 翼城县| 晋城| 东乌珠穆沁旗| 昌都县| 怀化市| 于都县| 开原市| 九龙城区| 西吉县| 绵阳市| 阜宁县| 乌鲁木齐县| 楚雄市|