object(mysqli_result)#13 (5) { ["current_field"]=> int(0) ["field_count"]=> int(25) ["lengths"]=> NULL ["num_rows"]=> int(1) ["type"]=> int(0) } 如何畫沒有背景的圓 How to draw a shape circle - 程序員論壇 - Powered by Discuz!

程序員論壇

標題: 如何畫沒有背景的圓 How to draw a shape circle [打印本頁]

作者: GreenCup    時間: 2021-4-8 10:35
標題: 如何畫沒有背景的圓 How to draw a shape circle
如何畫沒有背景的圓
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);
複製代碼





歡迎光臨 程序員論壇 (http://program.thesmartfire.com/) Powered by Discuz! X2.5