android仿iPhone自定义滚动条滑动选框视图
来源:互联网 发布:office2016 mac 破解版 编辑:程序博客网 时间:2024/06/05 09:23
上下滑动的滚动视图:
---------------------------------------------------------------------------------------------------------------------------------------------
可用来替换spinner下拉选框。
使用WheelView插件实现
WheelView插件包含这些,直接copy到项目对应位置即可:
Java类包括:,其中使用到两个drawable资源文件wheel_bg.xml和wheel_val.xml,内容分别为:
<?xml version="1.0" encoding="UTF-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle" > <gradient android:angle="90" android:centerColor="#ffdddddd" android:endColor="#ff333333" android:startColor="#ff333333" /> <stroke android:width="1.0dip" android:color="#ff333333" /> </shape> </item> <item android:bottom="1.0dip" android:left="4.0dip" android:right="4.0dip" android:top="1.0dip"> <shape android:shape="rectangle" > <gradient android:angle="90.0" android:centerColor="#ffffffff" android:endColor="#ffaaaaaa" android:startColor="#ffaaaaaa" /> </shape> </item></layer-list>
<?xml version="1.0" encoding="UTF-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" > <gradient android:angle="90.0" android:centerColor="#70222222" android:endColor="#70eeeeee" android:startColor="#70222222" /> <stroke android:width="1.0dip" android:color="#70333333" /></shape>
可自己修改这两文件内容。
---------------------------------------------------------------------------------------------
接下来使用WheelView,
首先布局文件中加入控件:
<LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_margin="8dp" android:layout_weight="3" android:background="@android:color/transparent" android:gravity="center_vertical|center_horizontal" android:orientation="horizontal" > <com.mywork.wheel.WheelView android:id="@+id/provinceCode" android:layout_width="0dp" android:layout_weight="1" android:layout_height="145dp" > </com.mywork.wheel.WheelView> <com.mywork.wheel.WheelView android:id="@+id/cityCode" android:layout_width="0dp" android:layout_weight="1" android:layout_height="145dp" > </com.mywork.wheel.WheelView> </LinearLayout>
接着在布局文件对应的Activity中:
private String[] provinceCodes = {"川", "京", "渝", "沪", "津", "黑", "吉", "辽", "蒙", "冀", "新", "甘", "青", "陕", "宁", "豫", "鲁", "晋", "皖", "鄂", "湘", "苏", "黔", "滇", "桂", "藏", "浙", "赣", "粤", "闽", "台", "琼", "港", "澳"};private String[] cityCodes = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.cart_query);RadioGroup cartTypeRadio = (RadioGroup)findViewById(R.id.cartTypeRadio);cartTypeRadio.setOnCheckedChangeListener(new OnCheckedChangeListener() {@Overridepublic void onCheckedChanged(RadioGroup radioGroup, int radioId) {//TODO...}});Button queryButton = (Button) findViewById(R.id.queryButton);queryButton.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View paramView) {Intent intent = new Intent(CartQuery.this, CartDetails.class);CartQuery.this.startActivity(intent);}});WheelView provinceCode = (WheelView) findViewById(R.id.provinceCode);provinceCode.setCyclic(true);provinceCode.setViewAdapter(new ArrayWheelAdapter<String>(this, provinceCodes));WheelView ciryCode = (WheelView)findViewById(R.id.cityCode);ciryCode.setCyclic(true);ciryCode.setViewAdapter(new ArrayWheelAdapter<String>(this, cityCodes));}......
最简单的WheelView滑动滚动视图实现了
---------------------
不求鼓掌,只求勿喷
- android仿iPhone自定义滚动条滑动选框视图
- Android 仿 iPhone 自定义滚条视图
- Android 仿 Iphone 自定义滚条视图(wheelview)
- Android 仿 Iphone 自定义滑动按钮(SlipButton)
- Android 仿 iPhone 自定义滑动按钮
- Android 仿 iphone 自定义滚动选择器
- Android Android HorizontalScrollView滚动实现仿今日头条滑动
- Android中仿淘宝头条,自定义控件,向上滚动
- android仿iphone滑动解锁
- 仿网易/今日头条滑动视图
- 仿今日头条亮度调节,字体调节(自定义视图),很好的滑动选择器
- android 隐藏滑动滚动条
- HTML自定义滚动条(仿网易邮箱滚动条)
- android Gallery 仿iPhone 图片滑动
- android Gallery 仿iPhone 图片滑动
- Android自定义SeekBar滑动条
- Android仿淘宝滚动的头条
- Android仿淘宝滚动的头条
- blob字段类型
- List of Game enging form wiki
- 嵌入式工程师经典面试题(转载...)
- linux-0.11调试教程,con_init函数和右上角的EGAc
- 【SQL】oracle date类型格式化输出
- android仿iPhone自定义滚动条滑动选框视图
- 未预编译文件“.aspx”,因此不能请求该文件
- 终端特殊字符
- PassBook
- 【观察者模式】
- 【转】mysql触发器的实战经验(触发器执行失败,sql会回滚吗)
- <feff> 问题
- JavaScript中的函数:函数的apply、call方法和length属性
- gml文件格式解析程序详解之源文件