欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

如何給Android應用設置圓角圖片

本篇文章給大家分享的是有關如何給Android應用設置圓角圖片,小編覺得挺實用的,因此分享給大家學習,希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。

沙市ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)建站的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:13518219792(備注:SSL證書合作)期待與您的合作!

主要原理是使用系統(tǒng)自帶api:

RoundedBitmapDrawableFactory

public class MainActivity extends AppCompatActivity {

 private ImageView mImgRectRound;
 private ImageView mImgRound;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  mImgRectRound = (ImageView) findViewById(R.id.img_rect_rounded);
  mImgRound = (ImageView) findViewById(R.id.img_rounded);
  rectRoundBitmap();
  roundBitmap();
 }

 private void rectRoundBitmap(){
  //得到資源文件的BitMap
  Bitmap image= BitmapFactory.decodeResource(getResources(),R.drawable.dog);
  //創(chuàng)建RoundedBitmapDrawable對象
  RoundedBitmapDrawable roundImg =RoundedBitmapDrawableFactory.create(getResources(),image);
  //抗鋸齒
  roundImg.setAntiAlias(true);
  //設置圓角半徑
  roundImg.setCornerRadius(30);
  //設置顯示圖片
  mImgRectRound.setImageDrawable(roundImg);
 }

 private void roundBitmap(){
  //如果是圓的時候,我們應該把bitmap圖片進行剪切成正方形, 然后再設置圓角半徑為正方形邊長的一半即可
  Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.dog);
  Bitmap bitmap = null;
  //將長方形圖片裁剪成正方形圖片
  if (image.getWidth() == image.getHeight()) {
   bitmap = Bitmap.createBitmap(image, image.getWidth() / 2 - image.getHeight() / 2, 0, image.getHeight(), image.getHeight());
  } else {
   bitmap = Bitmap.createBitmap(image, 0, image.getHeight() / 2 - image.getWidth() / 2, image.getWidth(), image.getWidth());
  }
  RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), bitmap);
  //圓角半徑為正方形邊長的一半
  roundedBitmapDrawable.setCornerRadius(bitmap.getWidth() / 2);
  //抗鋸齒
  roundedBitmapDrawable.setAntiAlias(true);
  mImgRound.setImageDrawable(roundedBitmapDrawable);
 }
}

布局文件:

<&#63;xml version="1.0" encoding="utf-8"&#63;>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:id="@+id/activity_main"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:orientation="vertical"
 tools:context="com.cjl.roundedbitmap.MainActivity">

 <ImageView
  android:id="@+id/img_rect_rounded"
  android:layout_width="200dp"
  android:layout_height="300dp"
  android:layout_marginTop="20dp"
  android:layout_gravity="center_horizontal"/>

 <ImageView
  android:id="@+id/img_rounded"
  android:layout_marginTop="20dp"
  android:layout_width="200dp"
  android:layout_height="200dp"
  android:layout_gravity="center_horizontal"/>
</LinearLayout>

以上就是如何給Android應用設置圓角圖片,小編相信有部分知識點可能是我們日常工作會見到或用到的。希望你能通過這篇文章學到更多知識。更多詳情敬請關注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

當前題目:如何給Android應用設置圓角圖片
網(wǎng)頁鏈接:http://aaarwkj.com/article20/ispsjo.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、微信公眾號App設計、網(wǎng)站排名虛擬主機、定制開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

h5響應式網(wǎng)站建設
日韩精品一区二区三区四区在线视频| 人妻少妇中文字幕在线播放 | 国产成人一区二区二区三区| 色婷婷国产精品高潮呻吟| 蜜臀久久精品国产综合| 国产午夜18久久久| 精品国产乱码一区二区三区四区| 国产精品三级av在线播放| 亚洲中少妇久久中文字幕| 哪里可以看黄色片日韩| 亚洲精品国产精品粉嫩| 日本韩国精品视频在线| 原创国产av剧情精品| 日韩一区精品视频一区二区| 最新国产精品欧美激情| 国产内射一级一片高清视频观看| 精品人妻一区二区三区蜜桃视频| 每日更新中文字幕粉嫩av| av剧情免费在线观看| 国产一区二区三区高潮爽| 91日本精品一区二区| 免费av不卡一区二区| 丰满人妻在线一区二区三区| 国产一区日本二区欧美三区| 亚洲国产韩国精品在线| 久热伊人精品国产中文 | 女同伦理视频在线观看| 久久女同互慰一区二区三区| 亚洲精品国产熟女久久| 少妇人妻系列中文在线| 国产av不卡精品影片| 久久亚洲精品中文字幕馆| 成人国产视频免费观看| 欧美亚洲清纯唯美另类| 国产精品岛国片在线观看| 亚洲va久久久噜噜噜久久狠| 精品人妻人伦一区二区三区| 久久精品国产亚洲av麻| 九九热99这里有精品| 丁香婷婷深情五月亚洲天堂| 综合激情丁香久久狠狠|