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方法