android圆形xml
Ⅰ android怎样在代码中创建shape圆oval
在drawable文件夹中创建bg_oval_shape.xml的xml文件
文件中添加如下代码
<?xmlversion="1.0"encoding="utf-8"?>
<shapexmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="#676767"/>
</shape>
3.在需要添加oval的控件中引用,代码如下:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/bg_oval_shape"/>
Ⅱ Android 圆形进度条控件
自定义控件圆形进度条,支持顶部圆环渐变色,以及动画功能.
res/vasues/attrs.xml
Ⅲ android 开发 imgview 怎么弄成圆形
imageview的属性中可以加入background来定义它的背景,将背景定义成一个圆形的drawable就可以了。
另一种办法,也可以自己定义一个view来显示圆形的图片,你可以参考http://blog.csdn.net/alan_biao/article/details/17379925来进行设计。
Ⅳ android 怎么把button变成圆形
使用shape,请看下面截图,例子来自于android学习手册,360手机助手中下载,里面有108个例子、源码还有文档。
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:Android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<!-- 填充的颜色 -->
<solid android:color="#FFFFFF"/>
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners android:radius="360dip"/>
<!-- padding: Button 里面的文字与Button边界的间隔 -->
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp"
/>
</shape>
-----Main layout文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/soft_info"
/>
<!—直接设置背景 -->
<Button
android:id="@+id/roundBtn1"
android:background="@drawable/btn_oval"
android:layout_width="50dip"
android:layout_height="50dip"
/>
<!— 调用shape自定义xml文件 -->
<Button
android:id="@+id/roundBtn"
android:text="椭圆按钮"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/main_menu_btnshape"
/>
</LinearLayout>
----acitivity文件
public class MyLifeActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Ⅳ android 如何把正方形图片显示圆形
Android应用开发中,很多头像都要求显示成圆形的,这就可以使用android的canvas、paint这些类来进行设置圆形,先设置paint的样式为圆形,然后把你要设置成圆形的图片重新赋值给paint这个类:canvas.drawBitmap(tempBmp, rect, rect, paint);
核心代码如下(引用这位前辈:http://blog.sina.com.cn/s/blog_7607703f0101dhlj.html,我增加一些注释,原来是没有注释):
java">packagecom.liang.round;
importandroid.annotation.SuppressLint;
importandroid.content.Context;
importandroid.graphics.Bitmap;
importandroid.graphics.Bitmap.Config;
importandroid.graphics.BitmapFactory;
importandroid.graphics.Canvas;
importandroid.graphics.Paint;
importandroid.graphics.PorterDuff;
importandroid.graphics.PorterDuffXfermode;
importandroid.graphics.Rect;
importandroid.view.View;
publicclassMyViewextendsView{
privateBitmapbmp=null;
privatePaintpaint=null;
publicMyView(Contextcontext){
super(context);
//TODOAuto-generatedconstructorstub
paint=newPaint();//实例化画笔类
BitmapFactory.Optionsoptions=newBitmapFactory.Options();
options.inJustDecodeBounds=true;
BitmapFactory.decodeResource(context.getResources(),R.drawable.test,options);//获得你存放在drawable下的正方形图片
options.inJustDecodeBounds=false;
BitmaptempBmp=BitmapFactory.decodeResource(context.getResources(),R.drawable.test,options);//实例化一个bitmap图片类
intwidth=options.outWidth;
intheight=options.outHeight;
intsize=width>height?height:width;//边框
intpos=(int)(size/2);
doubleradius=pos*Math.sin(45*180/Math.PI);//半径
size=(int)(radius*2);
pos=(int)(size/2);
bmp=Bitmap.createBitmap(size,size,Config.ARGB_8888);
Canvascanvas=newCanvas(bmp);
Rectrect=newRect(0,0,size,size);
paint.setAntiAlias(true);
canvas.drawCircle(pos,pos,(float)radius,paint);
paint.setXfermode(newPorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
canvas.drawBitmap(tempBmp,rect,rect,paint);
tempBmp.recycle();
}
@SuppressLint("DrawAllocation")
@Override
protectedvoidonDraw(Canvascanvas){
//TODOAuto-generatedmethodstub
super.onDraw(canvas);
if(bmp!=null){
if(!bmp.isRecycled()){
canvas.drawBitmap(bmp,100,100,paint);
}
}
}
}
Ⅵ 安卓imageview控件怎么设置成圆形
首先,定义定义圆形Imageview类:
importandroid.content.Context;
importandroid.graphics.Bitmap;
importandroid.graphics.Bitmap.Config;
importandroid.graphics.Canvas;
importandroid.graphics.Color;
importandroid.graphics.Paint;
importandroid.graphics.PorterDuff.Mode;
importandroid.graphics.PorterDuffXfermode;
importandroid.graphics.Rect;
importandroid.graphics.drawable.BitmapDrawable;
importandroid.graphics.drawable.Drawable;
importandroid.util.AttributeSet;
importandroid.widget.ImageView;
{
publicRoundImageView(Contextcontext){
super(context);
//TODOAuto-generatedconstructorstub
}
publicRoundImageView(Contextcontext,AttributeSetattrs){
super(context,attrs);
}
publicRoundImageView(Contextcontext,AttributeSetattrs,intdefStyle){
super(context,attrs,defStyle);
}
@Override
protectedvoidonDraw(Canvascanvas){
Drawabledrawable=getDrawable();
if(drawable==null){
return;
}
if(getWidth()==0||getHeight()==0){
return;
}
Bitmapb=((BitmapDrawable)drawable).getBitmap();
if(null==b)
{
return;
}
Bitmapbitmap=b.(Bitmap.Config.ARGB_8888,true);
intw=getWidth(),h=getHeight();
BitmaproundBitmap=getCroppedBitmap(bitmap,w);
canvas.drawBitmap(roundBitmap,0,0,null);
}
(Bitmapbmp,intradius){
Bitmapsbmp;
if(bmp.getWidth()!=radius||bmp.getHeight()!=radius)
sbmp=Bitmap.createScaledBitmap(bmp,radius,radius,false);
else
sbmp=bmp;
Bitmapoutput=Bitmap.createBitmap(sbmp.getWidth(),
sbmp.getHeight(),Config.ARGB_8888);
Canvascanvas=newCanvas(output);
finalintcolor=0xffa19774;
finalPaintpaint=newPaint();
finalRectrect=newRect(0,0,sbmp.getWidth(),sbmp.getHeight());
paint.setAntiAlias(true);
paint.setFilterBitmap(true);
paint.setDither(true);
canvas.drawARGB(0,0,0,0);
paint.setColor(Color.parseColor("#BAB399"));
canvas.drawCircle(sbmp.getWidth()/2+0.7f,sbmp.getHeight()/2+0.7f,
sbmp.getWidth()/2+0.1f,paint);
paint.setXfermode(newPorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(sbmp,rect,rect,paint);
returnoutput;
}
}
然后在别的布局文件中使用该控件即可,如:
<?xmlversion="1.0"encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/side_right"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="35dip"
android:orientation="vertical">
<<spanstyle="color:#ff0000;">com.founder.reader.view.RoundImageView</span>
android:id="@+id/right_login_head"
android:layout_width="60dip"
android:layout_height="60dip"
android:scaleType="centerInside"
android:src="@drawable/user"/>
Ⅶ android中怎么绘制这种圆形布局
圆形是个背景,可以通过xml定义背景图片
在res/drawable/下添加背景xml,test.xml代码如下
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item >
<shape android:shape="oval">
<padding android:top="2dp" android:right="2dp" android:bottom="2dp" android:left="2dp" />
<solid android:color="#00a0eb"/>
</shape>
</item>
<item >
<shape android:shape="oval">
<solid android:color="#ffffffff"/>
</shape>
</item>
</layer-list>
然后在layout下添加布局文件
代码如下
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="indi.zcm.dropdown.MainActivity" >
<RelativeLayout
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/test">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="27dp"
android:text="购买人数" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="45dp"
android:textSize="26sp"
android:text="32514" />
</RelativeLayout>
</RelativeLayout>
这个应该就是你要的效果
Ⅷ android 里用shape画圆,怎么填充颜色
Android里面使用shape设置控件的外形,例如一些圆角、填充的背景颜色、以及一些渐变的效果等,所以设置填充颜色,可通过设置shape.xml文件里的如下属性:
1
<solid android:color="@color/common_red" />
将shape文件放到android的button、textview组件上,就可以有填充背景颜色的效果,完整的代码如下:
1.shape.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?xml version="1.0" encoding="UTF-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false" >
<solid android:color="@color/common_red" />
<padding
android:left="2dp"
android:top="1dp"
android:right="2dp"
android:bottom="1dp" />
<solid
android:color="@color/common_red" />
<stroke
android:width="1dp"
android:color="@android:color/white" />
<size android:width="15dp"
android:height="15dp" />
2011年医师资格考试合格标准 356
2010年医师资格考试合格标准 351
2009年医师资格考试合格标准 345
2008年医师资格考试合格标准 359
医师资格证书是国内行医必不可少的"通行证",科目医师资格考试是评价申请医师资格者是否具备从事医师工作所必须通过的考试。
2014乡执业助理医师成绩已公布,乡镇执业助理医师成绩也同时公布,国家医学考试中心查。
乡镇执业助理医师分数线需等各省公布各省的。会在这段时间之内全部公布请耐心等待!
Ⅸ android 怎么利用shape实现圆形用户头像
<?xml version="1.0" encoding="UTF-8"?><shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false" >
<solid android:color="@color/common_red" />
<padding
android:left="2dp"
android:top="1dp"
android:right="2dp"
android:bottom="1dp" />
<solid
android:color="@color/common_red" />
<stroke
android:width="1dp"
android:color="@android:color/white" />
<size android:width="15dp"
android:height="15dp" /></shape>
Ⅹ 【android】使用drawable的xml文件和View.setClipToOutline()制作圆形ImageView
定义一个矩形,圆角为50dp
获取ImageView ,然后调用setClipToOutline方法