androidxml圓形
⑴ android 開發 imgview 怎麼弄成圓形
imageview的屬性中可以加入background來定義它的背景,將背景定義成一個圓形的drawable就可以了。
另一種辦法,也可以自己定義一個view來顯示圓形的圖片,你可以參考http://blog.csdn.net/alan_biao/article/details/17379925來進行設計。
⑵ android中 怎麼顯示一直圖片為圓形圖片
android中的imageview只能顯示矩形的圖片,這樣一來不能滿足我們其他的需求,比如要顯示圓形的圖片,這個時候,我們就需要自定義imageview了,其原理就是首先獲取到圖片的bitmap,然後進行裁剪圓形的bitmap,然後在ondraw()進行繪制圓形圖片輸出。
⑶ 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 畫圖-圓圈(紅、綠、黃)
畫紅圈
<?xml version="1.0" encoding="utf-8"?>
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false">
<solid android:color="@color/red" />
android:width="1dp"
android:color="@color/white" />
android:width="20dp"
android:height="20dp" />
</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/yellow" />
android:width="1dp"
android:color="@color/white" />
android:width="20dp"
android:height="20dp" />
</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/green" />
android:width="1dp"
android:color="@color/white" />
android:width="20dp"
android:height="20dp" />
</shape>
⑸ 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 如何把正方形圖片顯示圓形
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);
}
}
}
}
⑺ android的editText控制項用xml文件設置為圓角,但一旦換行左右下角的圓角又變為方角了,怎麼解決
做一張圓角的圖片,然後用E:\android-sdk\tools\draw9patch.bat處理成.9圖
⑻ 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 xml圓型頭像怎麼辦
android生成圓形頭像
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final Paint paint = new Paint();
//保證是方形,並且從中心畫
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int w;
int deltaX = 0;
int deltaY = 0;
if (width <= height) {
w = width;
deltaY = height - w;
} else {
w = height;
deltaX = width - w;
}
final Rect rect = new Rect(deltaX, deltaY, w, w);
final RectF rectF = new RectF(rect);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
//圓形,所有隻用一個
int radius = (int) (Math.sqrt(w * w * 2.0d) / 2);
canvas.drawRoundRect(rectF, radius, radius, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
⑽ 【android】使用drawable的xml文件和View.setClipToOutline()製作圓形ImageView
定義一個矩形,圓角為50dp
獲取ImageView ,然後調用setClipToOutline方法