Android 正圆

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="@dimen/dp_5">

    <TextView
        android:id="@+id/item_home_menu_tv"
        android:layout_width="200dp"
        android:textSize="30sp"
        android:layout_height="200dp"
        android:background="@drawable/home_menu_item_bg"
        android:gravity="center"
        android:padding="@dimen/dp_25"
        android:text="领取\n记录"
        android:textColor="@color/white" />

</RelativeLayout>

android:background="@drawable/home_menu_item_bg"


<?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="#2197F0" />
    <stroke
        android:width="11dp"
        android:color="@color/white" />
    <size
        android:width="19dp"
        android:height="19dp" />
</shape>

方式2  可动态修改颜色 

tvContent.setText(getItem(position).getContent());
            GradientDrawable drawable = new GradientDrawable();
            drawable.setShape(GradientDrawable.OVAL);
            String color = "#db5860";
            if (position == 0) {
                color = "#c6f47f";
            } else if (position == 1) {
                color = "#02a4eb";
            } else if (position == 2) {
                color = "#7ecff3";
            } else if (position == 3) {
                color = "#6eb203";
            } else if (position == 4) {
                color = "#bbbb00";
            } else if (position == 5) {
                color = "#f4bc73";
            } else if (position == 6) {
                color = "#e77d8a";
            } else if (position == 7) {
                color = "#be7dfa";
            } else if (position == 8) {
                color = "#7d7dfa";
            }
            drawable.setColor(Color.parseColor(color));//背景颜色
            drawable.setStroke(dpToPx(11), ContextCompat.getColor(getContext(), R.color.white));
            drawable.setSize(dpToPx(19), dpToPx(19));
            tvContent.setBackground(drawable);

相关推荐

  1. ps怎么扣

    2024-01-06 12:34:01       36 阅读
  2. opencv c++检测

    2024-01-06 12:34:01       38 阅读
  3. (())双结构扩展

    2024-01-06 12:34:01       20 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-06 12:34:01       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-06 12:34:01       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-06 12:34:01       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-06 12:34:01       18 阅读

热门阅读

  1. 详细介绍Spring Boot 和 Spring 有什么区别

    2024-01-06 12:34:01       28 阅读
  2. Ceph分布式存储

    2024-01-06 12:34:01       25 阅读
  3. 基于长短期神经网络lstm的求解方程

    2024-01-06 12:34:01       35 阅读
  4. C++面对对象编程

    2024-01-06 12:34:01       33 阅读
  5. instanceof 能够正确判断对象的原理是什么?

    2024-01-06 12:34:01       36 阅读
  6. copilot插件使用介绍

    2024-01-06 12:34:01       36 阅读
  7. 分享一个idea插件MyBatisX的Bug

    2024-01-06 12:34:01       39 阅读