日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

【Android】 横向纵向滚轮控件

發布時間:2023/12/13 综合教程 33 生活家
生活随笔 收集整理的這篇文章主要介紹了 【Android】 横向纵向滚轮控件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

項目需要縱向滾輪控件和橫向滾輪控件

    縱向滾輪控件:AndroidWheelDemo、AndroidWheel

    

    橫向滾輪控件:android 滾輪刻度尺的實現、android自己寫的類似刻度尺的東西。

    

縱向滾輪控件如下:

修改滾輪控件的布局可以在src/kankan/wheel/widget/WheelView.java和/res/drawable/wheel_val.xml

和/res/layout/wheel_text_item.xml和eslayout empitem.xml和srckankanwheeldemoCitiesActivity.java

修改控件字體大小、顏色:

CitiesActivity.java

   
    /**
     * Adapter for countries
     */
    private class CountryAdapter extends AbstractWheelTextAdapter {
        // Countries names
        ArrayList list;
        protected CountryAdapter(Context context,ArrayList list) {
            super(context, R.layout.tempitem, NO_RESOURCE);
            this.list = list;
            setItemTextResource(R.id.tempValue);
        }

        // Countries flags
        private int flags =R.drawable.tem_unit_dialog;

        @Override
        public View getItem(int index, View cachedView, ViewGroup parent) {
            View view = super.getItem(index, cachedView, parent);
            ImageView img = (ImageView) view.findViewById(R.id.tempImag);
            img.setImageResource(flags);
            return view;
        }
        
        @Override
        public int getItemsCount() {
            return list.size();
        }
        
        @Override
        protected CharSequence getItemText(int index) {
            return list.get(index)+"";
        }
    }

tempitem.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:gravity="center"
    >
    
    <TextView 
        android:id="@+id/tempValue"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="23dp"
        android:textColor="#ff6347"
        />
    <ImageView 
        android:id="@+id/tempImag"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/tem_unit_dialog"/>

    
</LinearLayout>

wheel_text_item.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="20dp"
    android:lines="1"
    android:textStyle="bold"
    android:textColor="#FF111111"
    android:layout_gravity="right" />

修改控件布局、背景:WheelView.java和wheel_val.xml

wheel_val.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- 當前項 -->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- 背景的過渡色 -->
    <gradient
        android:startColor="#70222222"
        android:centerColor="#70222222"
        android:endColor="#70EEEEEE"
        android:angle="90" />
        <!-- 分割線 -->
    <stroke android:width="1dp" android:color="#F0FF63" /> 
    
</shape>

wheel_bg.xml

<?xml version="1.0" encoding="utf-8"?>
 <!-- 將多個圖片或效果按照順序層疊起來 -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- 背景效果1 -->
    <item>
         <!--XML中定義的幾何形狀 -->
        <shape android:shape="rectangle">
             <!-- 漸變 -->
            <gradient
                android:startColor="#33CC99"
                android:centerColor="#33CC99"
                android:endColor="#33CC99"
                android:angle="90" />
                <!-- 描邊 --><!-- 左右邊緣線 -->
                <stroke android:width="1dp" android:color="#FF3399" />
        </shape>
    </item>
    <!-- 背景效果2 -->
    <item android:left="4dp" android:right="4dp" android:top="1dp" android:bottom="1dp">
         <!--XML中定義的幾何形狀 -->
        <shape android:shape="rectangle">
            <!-- 漸變 -->
            <gradient
                android:startColor="#FFFF33"
                android:centerColor="#FFFF33"
                android:endColor="#FFFF33"
                android:angle="90" />
        </shape>
    </item>
</layer-list>

?????????

?????????????
??
作者:xubuhang?????????????
??
出處:http://www.cnblogs.com/xubuhang/?
本文版權歸作者和博客園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責任的權利。?

?

總結

以上是生活随笔為你收集整理的【Android】 横向纵向滚轮控件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。