程序員論壇

 找回密碼
 立即註冊
搜索
熱搜: 活動 交友 discuz
查看: 1514|回復: 0
打印 上一主題 下一主題

如何畫沒有背景的圓 How to draw a shape circle

[複製鏈接]

8166

主題

1

好友

2萬

積分

版主

Rank: 7Rank: 7Rank: 7

跳轉到指定樓層
樓主
發表於 2021-4-8 10:35:35 |只看該作者 |倒序瀏覽
如何畫沒有背景的圓
How to draw a shape circle

circle.xml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <shape
  3.     xmlns:android="http://schemas.android.com/apk/res/android"
  4.     android:shape="oval">

  5.     <solid
  6.         android:color="#eeeeee"/>

  7.     <size
  8.         android:width="120dp"
  9.         android:height="120dp"/>
  10. </shape>
複製代碼
xxx.java
  1. Drawable shape = ResourcesCompat.getDrawable(_context.getResources(), R.drawable.circle, _context.getTheme());
  2.         TextView tv = new TextView(_context);
  3.         tv.setBackground(shape);


  4.         Broad_frame = new LinearLayout(_context);
  5.         lparams_summary = new LinearLayout.LayoutParams(ballSize, ballSize);
  6.         lparams_summary.setMargins(0, 0, 0, 0);
  7.         Broad_frame.setLayoutParams(lparams_summary);
  8.         Broad_frame.setPadding(0, 0, 0, 0);
  9.         Broad_frame.setOrientation(LinearLayout.HORIZONTAL);
  10.         Broad_frame.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
  11.         Broad_frame.setBackgroundColor(Color.TRANSPARENT);
  12.         Broad_frame.addView(tv);
複製代碼
回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

程序員論壇

GMT+8, 2024-9-20 06:26 , Processed in 0.030341 second(s), 19 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回頂部
HK Piece免費建立你的網上商店
Pocket Money Easy