麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 系統 > Android > 正文

android中實現指針滑動的動態效果方法

2020-04-11 12:30:20
字體:
來源:轉載
供稿:網友

復制代碼 代碼如下:

<FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#fff"
            android:paddingBottom="5dp"
            android:paddingLeft="5dp"
            android:paddingRight="2dp"
            >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="right"
                android:src="@drawable/up_icon"
                android:layout_marginTop="0dp"
                android:paddingTop="0dp" />

            <LinearLayout
                android:layout_width="240dip"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="7dp"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="left"
                    android:text="優"
                    android:textSize="12sp" />

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="left"
                    android:text="良"
                    android:textSize="12sp" />

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="left"
                    android:text="中等"
                    android:textSize="12sp" />

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="left"
                    android:text="不健康"
                    android:textSize="12sp" />

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="left"
                    android:text="有毒害"
                    android:textSize="12sp" />
            </LinearLayout>

           
            <LinearLayout
                android:layout_width="240dip"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="7dp"
                android:layout_marginTop="40dp"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="center_horizontal"
                    android:text="80"
                    android:textSize="12sp" />

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="center_horizontal"
                    android:text="120"
                    android:textSize="12sp" />

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="center_horizontal"
                    android:text="160"
                    android:textSize="12sp" />

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="center_horizontal"
                    android:text="200"
                    android:textSize="12sp" />

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="center_horizontal"
                    android:text="400"
                    android:textSize="12sp" />
            </LinearLayout>

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:src="@drawable/zhizhen"
                android:id="@+id/zhizhen"/>

            <ImageView
                android:id="@+id/dengji_img"
                android:layout_width="250dip"
                android:layout_height="wrap_content"
                android:layout_marginTop="25dp"
                android:src="@drawable/dengji_icon" />
        </FrameLayout>

上面這段代碼實現的布局為

首先,因為指針有壓著下面的滾動條,因此這是一個framelayout的布局。其次,要實現指針的勻速滾動,需要開啟一個線程,在線程中能夠實現利用循環,以及線程的休眠,通過控制指針所在圖標的padding屬性來實現滾動的動畫效果

復制代碼 代碼如下:

Handler myHandler =new Handler(){

        @Override
        public void handleMessage(Message msg) {
            // TODO Auto-generated method stub
            super.handleMessage(msg);
            //對于c的更改和循環應該是在線程中跑,要不run僅僅執行一次,           
            zhizhen.setPadding(c, 0, 0, 0);
        }

       
    };
    class MyThread extends Thread{

        @Override
        public void run() {
            //發送一個消息,通知主線程改變UI
         try {

             while(c<=input){
                 c=c+1;
                 this.sleep(10);
                 myHandler.sendEmptyMessage(0);                
             }

               
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 国产精品久久久久久影视 | 91情侣在线偷精品国产 | 日本成人在线免费 | 亚洲成人欧美 | 少妇一级淫片免费放4p | 黄色网欧美 | 欧美雌雄另类xxxxx | 性生活视频一级 | 久久精品亚洲成在人线av网址 | 国产精品999在线 | 国产精品免费小视频 | 欧美精品日日鲁夜夜添 | 欧美一级不卡视频 | 在线成人免费观看视频 | 日本一区二区久久 | 国产一区二区视频在线播放 | 姑娘第5集高清在线观看 | 99精品视频久久精品视频 | 成人精品视频网站 | 欧美一级性 | 美国av片在线观看 | 特片网久久| 国产在线欧美日韩 | 黑人日比视频 | 毛片a片免费看 | 国产精品久久久久久久av三级 | 日韩欧美高清片 | av成人免费 | 国产毛片在线看 | 日本免费一区二区三区四区 | 毛片免 | 精精国产xxxx视频在线野外 | 91成人亚洲 | 日韩午夜一区二区三区 | 国产日韩在线视频 | 毛片午夜 | 免费毛片电影 | 欧美中文字幕一区二区 | 中文字幕网址 | 日本视频免费看 | 久久成人国产精品 |