无论是网站,还是APP,人们都爱看一些新颖的视图效果。直角看多了,就想看看圆角,这几年刮起了一阵阵的圆角设计风:CSS新标准纳入圆角元素,特别是在iphone中几乎随处可见圆角设计,现在也开始出现很多圆角名片了。
现在就给大家实现一个圆角的ListView效果。 圆角的设计,我们并不追求到处都用,无处不用,android中有少数界面用直角确实容易显得锋利,和周边界面太过对比而显得不协调,比如大栏目列表,设置等等,而采用圆角实现,则会活泼,轻松的多,也融合的特别好。
先看下在IPhone中实现圆角效果的一个图片:
在Iphone中这种效果处处可见,但在Android中就需要我们手动实现了。
我们先看下示例运行效果图,如下所示:
实现原理:
通过判断ListView上点击的项的位置,我们切换不同的选择器,当然这个切换的动作我们需要定义在重写ListView的onInterceptTouchEvent()方法中。
if(itemnum==0){
if(itemnum==(getAdapter().getCount()-1)){
//只有一项
setSelector(R.drawable.app_list_corner_round);
}else{
//第一项
setSelector(R.drawable.app_list_corner_round_top);
}
}else if(itemnum==(getAdapter().getCount()-1))
//最后一项
setSelector(R.drawable.app_list_corner_round_bottom);
else{
//中间一项
setSelector(R.drawable.app_list_corner_shape);
}
定义选择器
如果只有一项,我们需要四个角都是圆角,app_list_corner_round.xml文件定义如下:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="#BFEEFF"
android:endColor="#40B9FF"
android:angle="270"/>
<corners android:topLeftRadius="6dip"
android:topRightRadius="6dip"
android:bottomLeftRadius="6dip"
android:bottomRightRadius="6dip"/>
</shape>
如果是顶部第一项,则上面两个角为圆角,app_list_corner_round_top.xml定义如下:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="#BFEEFF"
android:endColor="#40B9FF"
android:angle="270"/>
<corners android:topLeftRadius="6dip"
android:topRightRadius="6dip"/>
</shape>
如果是底部最后一项,则下面两个角为圆角,app_list_corner_round_bottom.xml定义如下:
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#BFEEFF"
android:endColor="#40B9FF"
android:angle="270"/> <corners android:bottomLeftRadius="6dip"
android:bottomRightRadius="6dip" />
</shape>
如果是中间项,则应该不需要圆角, app_list_corner_shape.xml定义如下:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="#BFEEFF"
android:endColor="#40B9FF"
android:angle="270"/>
</shape>
分享到:
相关推荐
android ListView圆角显示的效果
Android实现iphone圆角ListView和点击的效果 Android实现iphone圆角ListView和点击的效果
android listview实现圆角。 有注释能看懂。
Android ListView边框圆角美化,可以用来仿iphone的个别界面。相当有用。美观。
Android列表之圆角ListView选中实现方式1,工程导入就可以运行
android, 圆角listview,listview回弹效果,scrollview 回弹效果,主流软件设置页
Android列表之圆角ListView选中实现方式二,导入工程直接可以运行
android圆角的listview
Android列表之圆角ListView选中源码方法一,直接导入工程就可运行看效果
在Android应用程序开发中,我们经常用到ListView这个控件,可能大家会对方方正正的ListView控件感到厌烦,这里来实现圆角的ListView,并放在ScrollView控件中
android 圆角listview(仿iphone).现在流行的就两张方式,一种是通过判断item位置更换背景图片,背景用.9.png图片;一种就是上传的这种通过drawable文件shape设置corners。
Android 圆角Listview
android 圆角listview 在解决listview与滚动条之间的纠结问题基础上添加了图片和监听
android实现的listView圆角效果
利用textView做成的一个具有圆角listview效果的例子,包含textView的点击效果等的学习
android listview 圆角的实现方案,模仿Iphone的UITableView 对应的工程
仿IOS圆角listview ,直接看代码,只是定义一个样式
android 圆角listview 直接上源码
Android仿ios圆角分组listView,自定义控件,自感觉效果很赞。使用方法:RoundAdapte类的两个方法根据你的需求重写掉即可
本文演示如何在Android中实现ListView圆角效果。 无论是网站,还是APP,人们都爱看一些新颖的视图效果。直角看多了,就想看看圆角,这几年刮起了一阵阵的圆角设计风:CSS新标准纳入圆角元素,特别是在iphone中几乎...