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

Android實現(xiàn)圓圈倒計時

 更新時間:2022年08月09日 11:01:52   作者:零下37度5  
這篇文章主要為大家詳細介紹了Android實現(xiàn)圓圈倒計時,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了Android實現(xiàn)圓圈倒計時的具體代碼,供大家參考,具體內容如下

1. 顯示效果如下

2. 首先是創(chuàng)建shape的xml文件

在res/drawable目錄下創(chuàng)建 shape_round_textview.xml文件,文件代碼如下:

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
? ? android:shape="oval"
? ? android:useLevel="false">
? ? <solid
? ? ? ? android:color="#FFFCFC" />
? ? <stroke
? ? ? ? android:width="1dp"
? ? ? ? android:color="#7468BE"
? ? />
? ? <size
? ? ? ? android:width="50dp"
? ? ? ? android:height="50dp"
? ? />
</shape>

3.然后就是在Layout布局文件里面使用定義的shape

我自己做的在一個橫向布局的LinearLayout里面把倒計時放到最右邊(中間TextView的目的是把倒計時的TextView擠到最右邊去 )顯示如圖:

布局文件代碼:

<LinearLayout
? ? ? ? android:layout_marginTop="20dp"
? ? ? ? android:orientation="horizontal"
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="wrap_content">
? ? ? ? <ImageButton
? ? ? ? ? ? android:layout_marginLeft="10dp"
? ? ? ? ? ? android:id="@+id/go_back"
? ? ? ? ? ? android:layout_width="36dp"
? ? ? ? ? ? android:layout_height="36dp"
? ? ? ? ? ? android:background="@drawable/go_back"
? ? ? ? ? ? />
? ? ? ? <TextView
? ? ? ? ? ? android:layout_width="0dp"
? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? android:layout_weight="1"
? ? ? ? ? ? />
? ? ? ? <TextView
? ? ? ? ? ? android:layout_marginRight="10dp"
? ? ? ? ? ? android:id="@+id/time_down"
? ? ? ? ? ? android:layout_width="50dp"
? ? ? ? ? ? android:layout_height="50dp"
? ? ? ? ? ? android:text="50"
? ? ? ? ? ? android:textSize="15sp"
? ? ? ? ? ? android:gravity="center"
? ? ? ? ? ? android:background="@drawable/shape_round_textview"
? ? ? ? ? ? />

</LinearLayout>

4.最后是java文件里的代碼

public class StateModeActivity extends AppCompatActivity {

? ? private TextView tx_time;
? ??
? ? @Override
? ? protected void onCreate(Bundle savedInstanceState) {
? ? ? ? super.onCreate(savedInstanceState);
? ? ? ? //隱藏默認標題欄
? ? ? ? if (getSupportActionBar() != null){
? ? ? ? ? ? getSupportActionBar().hide();
? ? ? ? }
? ? ? ? setContentView(R.layout.activity_state_mode);
? ? ? ??
? ? ? ? tx_time = findViewById(R.id.time_down);
? ? ? ? //倒計時顯示
? ? ? ? ValueAnimator animator = ValueAnimator.ofInt(50,0);
? ? ? ? //設置時間
? ? ? ? animator.setDuration(50000);
? ? ? ? //均勻顯示
? ? ? ? animator.setInterpolator(new LinearInterpolator());
? ? ? ? animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
? ? ? ? ? ? @Override
? ? ? ? ? ? public void onAnimationUpdate(ValueAnimator animation) {
? ? ? ? ? ? ? ? int value = (Integer) animation.getAnimatedValue();
? ? ? ? ? ? ? ? tx_time.setText(value+"");
? ? ? ? ? ? ? ? if(value==0)
? ? ? ? ? ? ? ? ? ? startActivity(new Intent(StateModeActivity.this,MainActivity.class));
? ? ? ? ? ? }
? ? ? ? });
? ? ? ? animator.start();
? ? ? ? }

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • Flutter路由傳遞參數(shù)及解析實現(xiàn)

    Flutter路由傳遞參數(shù)及解析實現(xiàn)

    這篇文章介紹了Flutter路由傳遞參數(shù)及解析實現(xiàn)的方法,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2021-11-11
  • Android編程之下拉菜單Spinner控件用法示例

    Android編程之下拉菜單Spinner控件用法示例

    這篇文章主要介紹了Android編程之下拉菜單Spinner控件用法,結合簡單實例形式分析了Android下拉菜單Spinner的布局與功能相關實現(xiàn)技巧,需要的朋友可以參考下
    2017-07-07
  • Android添加水印的正確方法 只要三步!

    Android添加水印的正確方法 只要三步!

    這篇文章主要介紹了Android添加水印的正確方法,僅僅三步輕松實現(xiàn)為圖片添加水印功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • Android小程序實現(xiàn)簡易QQ界面

    Android小程序實現(xiàn)簡易QQ界面

    這篇文章主要為大家詳細介紹了Android小程序實現(xiàn)簡易QQ界面,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-05-05
  • Android手機開發(fā)設計之記事本功能

    Android手機開發(fā)設計之記事本功能

    這篇文章主要為大家詳細介紹了Android手機開發(fā)設計之記事本功能,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-05-05
  • Android實現(xiàn)屏幕各尺寸的獲取的示例

    Android實現(xiàn)屏幕各尺寸的獲取的示例

    本篇文章主要介紹了Android實現(xiàn)屏幕各尺寸的獲取的示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-09-09
  • android使用NotificationListenerService監(jiān)聽通知欄消息

    android使用NotificationListenerService監(jiān)聽通知欄消息

    本篇文章主要介紹了android使用NotificationListenerService監(jiān)聽通知欄消息,具有一定的參考價值,感興趣的小伙伴們可以參考一下。
    2017-01-01
  • Android超詳細講解組件ScrollView的使用

    Android超詳細講解組件ScrollView的使用

    本節(jié)帶來的是Android基本UI控件中的第十個:ScrollView(滾動條),或者我們應該叫他?豎直滾動條,對應的另外一個水平方向上的滾動條:HorizontalScrollView,先讓我們來了解ScrollView
    2022-03-03
  • Android View 布局流程(Layout)全面解析

    Android View 布局流程(Layout)全面解析

    這篇文章主要為大家全面解析了Android View 布局流程Layout,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-02-02
  • Android中圖片壓縮的三種實現(xiàn)方法

    Android中圖片壓縮的三種實現(xiàn)方法

    在?Android?開發(fā)中,圖片壓縮是一個重要的優(yōu)化手段,這篇文章為大家整理了幾種主流的圖片壓縮方法,感興趣的小伙伴可以跟隨小編一起學習一下
    2025-02-02

最新評論

唐山市| 石楼县| 淅川县| 海兴县| 康定县| 高雄市| 天水市| 辽中县| 临泉县| 晋中市| 平舆县| 沙河市| 正镶白旗| 内黄县| 乌拉特后旗| 平武县| 蓬溪县| 和龙市| 泾阳县| 宝丰县| 苏尼特右旗| 宿迁市| 西华县| 厦门市| 淅川县| 远安县| 余干县| 化德县| 梓潼县| 宝兴县| 怀集县| 新宾| 阿拉善左旗| 玉环县| 陆川县| 察雅县| 绵竹市| 长海县| 鄂伦春自治旗| 巩留县| 苍溪县|