欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android使用Shape實現(xiàn)ProgressBar樣式實例

 更新時間:2017年04月20日 09:00:05   作者:AlvinL  
本篇文章主要介紹了Android使用Shape實現(xiàn)ProgressBar樣式實例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

使用Shape實現(xiàn)樣式

使用Shape中的ring實現(xiàn),如下布局ring.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
  android:shape="ring"
  android:thickness="5dp"
  android:useLevel="false" >
  <gradient
    android:endColor="#888"
    android:startColor="#ccc"
    android:type="sweep"
    android:useLevel="false" />
</shape>

使用rotate使之旋轉(zhuǎn)

如下progressbar.xml

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

注意:其中fromDegrees與toDegrees之差要是360的倍數(shù),不然中間會有轉(zhuǎn)的時候會跳一下,另外,這個差越大就轉(zhuǎn)得越快,具體效果大家可以自行試一下

使用

<ProgressBar
  style="?android:attr/progressBarStyleLarge"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:indeterminateDrawable="@drawable/progressbar" <!-- 這里使用自定義的progressbar樣式 -->
/>

更簡單的方法

直接使用一個布局文件就可以實現(xiàn):

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

  <shape
    android:shape="ring"
    android:thickness="5dp"
    android:useLevel="false" >
    <gradient
      android:endColor="#888"
      android:startColor="#ccc"
      android:type="sweep"
      android:useLevel="false" />
  </shape>
</rotate>

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論