列表项对Android的圆角? [英] Rounded corner of list item on Android?

查看:154
本文介绍了列表项对Android的圆角?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置属性来实现圆角在的ListView 每个项目? 烦请举个例子,如果你可以,谢谢!

例如: http://www.flickr.com/photos/jaxxdotorg/3640222441/在/设置72157619952823330 /

编辑: 这是我的code这里的答案。

 < XML版本=1.0编码=UTF-8&GT?;
<形状
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
<梯度
    机器人:startColor =#FFFF
    机器人:endColor =#fddd
    机器人:角=270/>
<角落
    机器人:半径=13dp/>
<中风
    机器人:宽=1DP
    机器人:颜色=#feee/>
< /形状>
 

解决方案

您可以通过形状实现这一目标。

检出的形状绘制对象文档

 < XML版本=1.0编码=UTF-8&GT?;
<形状
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
    <角落
        机器人:半径=12dp/>
    <中风
        机器人:宽=1DP
        机器人:颜色=@色/蓝色/>
< /形状>
 

的角元素指定圆角的大小。现在,所有你需要做的就是指定此绘制为背景,以每个列表元素。

How to setup the attribute to achieve the rounded corner for each item in the ListView? Please kindly give an example if you can, thanks!

for example: http://www.flickr.com/photos/jaxxdotorg/3640222441/in/set-72157619952823330/

EDIT: That's my code here for the answer.

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
    android:startColor="#ffff"
    android:endColor="#fddd"
    android:angle="270" />
<corners
    android:radius="13dp" />
<stroke
    android:width="1dp"
    android:color="#feee" />
</shape>

解决方案

You can achieve this with shapes.

Checkout the Shape Drawable documentation

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android">
    <corners
        android:radius="12dp"/>
    <stroke
        android:width="1dp"
        android:color="@color/blue" />
</shape>

The corner element specifies the size of the rounded corner. Now all you need to do is specify this drawable as the background to each list element.

这篇关于列表项对Android的圆角?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆