圆角矩形形状图像中的android从服务器检索 [英] Rounded Rectangle shape to image retrieving from server in android

查看:143
本文介绍了圆角矩形形状图像中的android从服务器检索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想给圆角矩形造型,我从服务器获取它们,并在列表视图中显示图像。
目前,我能够使图像在一个圆角矩形形状,在我的绘制文件夹中。但要找到从服务器获取图像的困难。

请让我知道我可以做到这一点。

感谢您


解决方案

圆角查看,只需创建绘制XML,应用半径率到图像的角落,以及你可以将背景色您的看法也是如此,看看下面code和步骤。

中创建一个名为RES的绘制对象的一个文件夹,保持低于XML的绘制,你可以在运行时设置或布局XML到视图。


  

round_border.xml


 <?XML版本=1.0编码=UTF-8&GT?;
<形状的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
[固体机器人:颜色=#5a5a5a/>
<角落的an​​droid:半径=10px的/>
<填充机器人:左=20dp机器人:顶部=20dp机器人:右=20dp机器人:底部=20dp/>
< /形状>


  

中的XML


 的android:背景=@绘制/ round_border


  

java的code


  ImageView的IM =(ImageView的)findViewById(R.id.imageView2);
    im.setBackgroundResource(R.drawable.round_border);

I want to give rounded rectangle shape to the images that I am fetching them from the server and displaying in list view. Currently I am able to make the images in a rounded rectangle shape which are available in my drawable folder. But finding the difficulties for the images fetching from the server.

Please let me know how can I do this..

Thank You

解决方案

Round corners to view, simply create xml for drawable, apply Radius rate to your image corner as well as you can apply background color to your view too, check below code and steps.

Create one folder named Drawable within Res, keep below xml in drawable and you can set at runtime or in layout xml to your view.

round_border.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#5a5a5a"/>
<corners android:radius="10px"/>
<padding android:left="20dp" android:top="20dp" android:right="20dp" android:bottom="20dp"/> 
</shape>

Within xml

 android:background="@drawable/round_border"

Jave code

ImageView im=(ImageView)findViewById(R.id.imageView2);
    im.setBackgroundResource(R.drawable.round_border);

这篇关于圆角矩形形状图像中的android从服务器检索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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