Android小工具自定义view课表

本文实例为大家分享了Android自定义view课表的具体代码,供大家参考,具体内容如下

这里是模拟课表,数据写死了的,不过也可以通过抓包获取教务系统课表

1.xml文件

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:background="#A5D6A7"
    android:fitsSystemWindows="true"
    android:layout_height="match_parent"
    tools:context=".KebiaoActivity">

    <!--        <com.baidu.lbsapi.panoramaview.PanoramaView-->
    <!--            android:id="@+id/panorama"-->
    <!--            android:layout_width="match_parent"-->
    <!--            android:layout_height="match_parent"-->
    <!--            android:clickable="true" />-->

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/constraintLayout"
            android:layout_width="match_parent"
            android:layout_height="250dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <ImageView
                android:id="@+id/back"
                android:layout_width="25dp"
                android:layout_height="25dp"
                android:layout_marginStart="15dp"
                app:layout_constraintBottom_toBottomOf="@+id/textView16"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="@+id/textView16"
                app:srcCompat="@mipmap/fanhui"
                android:layout_marginLeft="15dp" />

            <TextView
                android:id="@+id/textView16"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="课表"
                android:textColor="#ffffff"
                android:textSize="26sp"
                android:layout_marginTop="10dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.25"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/ershou"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="本周课表"
                android:textColor="@color/white"
                android:textSize="60sp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_bias="0.45" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Schedule of the week"
                android:textColor="@color/white"
                android:textSize="20sp"
                android:layout_marginTop="10dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.7"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/ershou" />
        </androidx.constraintlayout.widget.ConstraintLayout>

        <RelativeLayout
            android:id="@+id/kebiao22"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_constraintTop_toBottomOf="@+id/constraintLayout">

            <TextView android:id="@+id/test_empty"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="11\n月"
                android:gravity="center"

                android:background="@drawable/course_text_view_bg"
                />

            <TextView android:id="@+id/test_monday_course"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="23日\n周一"
                android:layout_toRightOf="@id/test_empty"
                android:background="@drawable/course_text_view_bg"
                android:gravity="center"

                />

            <TextView android:id="@+id/test_tuesday_course"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="24日\n周二"
                android:layout_toRightOf="@id/test_monday_course"
                android:background="@drawable/course_text_view_bg"
                android:gravity="center"

                />

            <TextView android:id="@+id/test_wednesday_course"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="25日\n周三"
                android:layout_toRightOf="@id/test_tuesday_course"
                android:background="@drawable/course_text_view_bg"
                android:gravity="center"

                />

            <TextView android:id="@+id/test_thursday_course"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="26日\n周四"
                android:layout_toRightOf="@id/test_wednesday_course"
                android:background="@drawable/course_text_view_bg"
                android:gravity="center"

                />

            <TextView android:id="@+id/test_friday_course"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="27日\n周五"
                android:layout_toRightOf="@id/test_thursday_course"
                android:background="@drawable/course_text_view_bg"
                android:gravity="center"

                />

            <TextView android:id="@+id/test_saturday_course"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="28日\n周六"
                android:layout_toRightOf="@id/test_friday_course"
                android:background="@drawable/course_text_view_bg"
                android:gravity="center"

                />

            <TextView android:id="@+id/test_sunday_course"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="29日\n周日"
                android:layout_toRightOf="@id/test_saturday_course"
                android:background="@drawable/course_text_view_bg"
                android:gravity="center"

                />

        </RelativeLayout>
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="800dp"
            android:id="@+id/test_course_rl"
            app:layout_constraintTop_toBottomOf="@id/kebiao22"
            >
        </RelativeLayout>

    </androidx.constraintlayout.widget.ConstraintLayout>

</ScrollView>

course_text_view_bg

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    >

    <solid android:color="#ffffff"/>
    <stroke android:width="0.2dp"
        android:color="#AEAAAA"/>

</shape>

2.activity代码

public class KebiaoActivity extends AppCompatActivity {
    /** 第一个无内容的格子 */
    protected TextView empty;
    /** 星期一的格子 */
    protected TextView monColum;
    /** 星期二的格子 */
    protected TextView tueColum;
    /** 星期三的格子 */
    protected TextView wedColum;
    /** 星期四的格子 */
    protected TextView thrusColum;
    /** 星期五的格子 */
    protected TextView friColum;
    /** 星期六的格子 */
    protected TextView satColum;
    /** 星期日的格子 */
    protected TextView sunColum;
    /** 课程表body部分布局 */
    protected RelativeLayout course_table_layout;
    /** 屏幕宽度 **/
    protected int screenWidth;
    /** 课程格子平均宽度 **/
    protected int aveWidth;
    int gridHeight1 = 0;
    //(0)对应12节;(2)对应34节;(4)对应56节;(6)对应78节;(8)对应于9 10节
    int[] jieci = {0,2,3,5,4,6,8};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT >= 21){
            View decorView = getWindow().getDecorView();
            decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            getWindow().setStatusBarColor(Color.TRANSPARENT);

        }
        setContentView(R.layout.activity_kebiao);

        ImageView mImageView=findViewById(R.id.back);
        mImageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                finish();
            }
        });
        //获得列头的控件
        empty = (TextView) this.findViewById(R.id.test_empty);
        monColum = (TextView) this.findViewById(R.id.test_monday_course);
        tueColum = (TextView) this.findViewById(R.id.test_tuesday_course);
        wedColum = (TextView) this.findViewById(R.id.test_wednesday_course);
        thrusColum = (TextView) this.findViewById(R.id.test_thursday_course);
        friColum = (TextView) this.findViewById(R.id.test_friday_course);
        satColum  = (TextView) this.findViewById(R.id.test_saturday_course);
        sunColum = (TextView) this.findViewById(R.id.test_sunday_course);
        course_table_layout = (RelativeLayout) this.findViewById(R.id.test_course_rl);
        DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        //屏幕宽度
        int width = dm.widthPixels;
        //平均宽度
        int aveWidth = width / 8;
        //第一个空白格子设置为25宽
        empty.setWidth(aveWidth * 3/4);
        monColum.setWidth(aveWidth * 33/32 + 1);
        tueColum.setWidth(aveWidth * 33/32 + 1);
        wedColum.setWidth(aveWidth * 33/32 + 1);
        thrusColum.setWidth(aveWidth * 33/32 + 1);
        friColum.setWidth(aveWidth * 33/32 + 1);
        satColum.setWidth(aveWidth * 33/32 + 1);
        sunColum.setWidth(aveWidth * 33/32 + 1);
        this.screenWidth = width;
        this.aveWidth = aveWidth;
        int height = dm.heightPixels;
        int gridHeight = height / 10;
        gridHeight1 = gridHeight;
        //设置课表界面
        //动态生成10 * maxCourseNum个textview
        for(int i = 1; i <= 12; i ++){

            for(int j = 1; j <= 8; j ++){

                TextView tx = new TextView(KebiaoActivity.this);
                tx.setId((i - 1) * 8  + j);
                //除了最后一列,都使用course_text_view_bg背景(最后一列没有右边框)
                tx.setBackgroundDrawable(KebiaoActivity.this.
                        getResources().getDrawable(R.drawable.course_text_view_bg));
                //相对布局参数
                RelativeLayout.LayoutParams rp = new RelativeLayout.LayoutParams(
                        aveWidth * 33 / 32 + 1,
                        gridHeight);
                //文字对齐方式
                tx.setGravity(Gravity.CENTER);
                //字体样式
//                tx.setTextAppearance(this, R.style.courseTableText);
//                //如果是第一列,需要设置课的序号(1 到 12)
                if(j == 1)
                {
                    tx.setText(String.valueOf(i));
                    rp.width = aveWidth * 3/4;
                    //设置他们的相对位置
                    if(i == 1)
                        rp.addRule(RelativeLayout.BELOW, empty.getId());
                    else
                        rp.addRule(RelativeLayout.BELOW, (i - 1) * 8);
                }
                else
                {
                    rp.addRule(RelativeLayout.RIGHT_OF, (i - 1) * 8  + j - 1);
                    rp.addRule(RelativeLayout.ALIGN_TOP, (i - 1) * 8  + j - 1);
                    tx.setText("");
                }

                tx.setLayoutParams(rp);
                course_table_layout.addView(tx);
            }
        }

        setCourseMessage(1,jieci[1],"软件工\n程@含\n浦校区\n3508教\n室\n");
        setCourseMessage2(2,jieci[0],"嵌入式\n系统...\n@含浦\n校区\n3204教\n室");
        setCourseMessage(3,jieci[1],"计算机\n图形\n学@含\n浦校区\n3310教\n室");
        setCourseMessage2(4,jieci[0],"计算机\n网络...\n@含浦\n校区\n3311教\n室");
        setCourseMessage2(5,jieci[0],"嵌入式\n系统...\n@h含浦\n校区嵌入\n式实验室");
        setCourseMessage(5,jieci[1],"java...\n@h含浦\n校区12\n机房\n(65)");
        setCourseMessage(1,jieci[3],"人工智\n能原\n理@含\n浦校区\n3306教\n");
        setCourseMessage2(2,jieci[2],"计算机\n网络...\n@含浦\n校区\n2204教\n室");
        setCourseMessage(5,jieci[3],"操作系\n统原\n理@含\n浦校区\n12机房\n(65)");

    }
//菜单
//    @Override
//    public boolean onCreateOptionsMenu(Menu menu) {
//        // Inflate the menu; this adds items to the action bar if it is present.
//        getMenuInflater().inflate(R.menu.main, menu);
//        return true;
//    }

    public void setCourseMessage(int xingqi,int jieci,String courseMessage){
        //五种颜色的背景
        int[] background = {R.drawable.course_info_blue, R.drawable.course_info_green,
                R.drawable.course_info_red, R.drawable.course_info_zisi,
                R.drawable.course_info_yellow};
        // 添加课程信息
        TextView courseInfo = new TextView(this);
        courseInfo.setText(courseMessage);
        //该textview的高度根据其节数的跨度来设置
        RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(
                aveWidth * 31 / 32,
                (gridHeight1 - 5) * 3 );
        //textview的位置由课程开始节数和上课的时间(day of week)确定
        rlp.topMargin = 5 + jieci * gridHeight1;
        rlp.leftMargin = 5;
        // 偏移由这节课是星期几决定
        rlp.addRule(RelativeLayout.RIGHT_OF, xingqi);
        //字体剧中
        courseInfo.setGravity(Gravity.CENTER);
        // 设置一种背景
        Random random = new Random();
        courseInfo.setBackgroundResource(background[random.nextInt(5)]);
        courseInfo.setTextSize(12);
        courseInfo.setLayoutParams(rlp);
        courseInfo.setTextColor(Color.WHITE);
        //设置不透明度
        courseInfo.getBackground().setAlpha(222);
        course_table_layout.addView(courseInfo);
    }
    public void setCourseMessage2(int xingqi,int jieci,String courseMessage){
        //五种颜色的背景
        int[] background = {R.drawable.course_info_blue, R.drawable.course_info_green,
                R.drawable.course_info_red, R.drawable.course_info_zisi,
                R.drawable.course_info_yellow};
        // 添加课程信息
        TextView courseInfo = new TextView(this);
        courseInfo.setText(courseMessage);
        //该textview的高度根据其节数的跨度来设置
        RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(
                aveWidth * 31 / 32,
                (gridHeight1 - 5) * 2 );
        //textview的位置由课程开始节数和上课的时间(day of week)确定
        rlp.topMargin = 5 + jieci * gridHeight1;
        rlp.leftMargin = 5;
        // 偏移由这节课是星期几决定
        rlp.addRule(RelativeLayout.RIGHT_OF, xingqi);
        //字体剧中
        courseInfo.setGravity(Gravity.CENTER);
        // 设置一种背景
        Random random = new Random();
        courseInfo.setBackgroundResource(background[random.nextInt(5)]);
        courseInfo.setTextSize(12);
        courseInfo.setLayoutParams(rlp);
        courseInfo.setTextColor(Color.WHITE);
        //设置不透明度
        courseInfo.getBackground().setAlpha(222);
        course_table_layout.addView(courseInfo);
    }

}

3.资源文件

course_info_blue

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    >

    <solid android:color="#4FC3F7"/>

</shape>

course_info_green

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    >

    <solid android:color="#81C784"/>

</shape>

course_info_red

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    >

    <solid android:color="#E57373"/>

</shape>

course_info_zisi

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    >

    <solid android:color="#9575CD"/>

</shape>

course_info_yellow

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    >

    <solid android:color="#FFB74D"/>

</shape>

4.运行

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。

(0)

相关推荐

  • Android自定义View实现跟随手指移动

    对View的移动,实现的方法有好几种,原理是通过改变View的位置来移动View,下面来实现这样的效果 动画的方法 通过改变View的tranlationX和tranlationY的值来实现移动,首先来写一个自定义View类,重写onTouchEvent方法,实现构造方法 public class MyView extends View {     public MyView(Context context) {         super(context);     }     public

  • Android自定义View实现水波纹扩散效果

    目录 1.创建RippleView.class, 继承与View 1.1特殊属性解释 1.2新建attrs.xml文件(res/values) 1.3初始化画笔 2.开始绘制onDraw() 效果:水波纹扩散 场景:雷达.按钮点击效果.搜索等 实现:先上效果图,之前记得支付宝有一个咻一咻,当时就是水波纹效果,实现起来一共两步,第一画内圆,第二画多个外圆,不同时创建有间隔创建然后缓慢增大外圆半径,到达最远距离时移除掉,扩散时把透明度从255-1不断赋值即可.复杂在第二步,开工. 开工 1.创建Ri

  • Android自定义View实现天气预报折线图

    本文实例为大家分享了Android自定义View画天气预报折线图的具体代码,供大家参考,具体内容如下 效果图如下: 刚开始尝试用第三方画曲线的框架来画效果图,后来发现曲线间的阴影当有负数的度数的时候画不出来,而且不需要点击放大.点点可点的效果,用框架显得很臃肿,所以最后用自定义View来画的折线图.自定义画折线图的大致思路:这个图是有多个四边形组成的(4个点连接起来就是一个四边形),两边延伸:添加四个多余的点,将左右的边距设置成负数即可. 代码如下: public class WeatherCh

  • Android自定义view实现侧滑栏详解

    目录 前言 需求 效果图 编写代码 主要问题 前言 上一篇文章学了下自定义View的onDraw函数及自定义属性,做出来的滚动选择控件还算不错,就是逻辑复杂了一些.这篇文章打算利用自定义view的知识,直接手撕一个安卓侧滑栏,涉及到自定义LayoutParams.带padding和margin的measure和layout.利用requestLayout实现动画效果等,有一定难度,但能重新学到很多知识! 需求 这里类似旧版QQ(我特别喜欢之前的侧滑栏),有两层页面,滑动不是最左侧才触发的,而是从

  • Android自定义View实现时钟功能

    最近在练习自定义view, 想起之前面试的时候笔试有道题是写出自定义一个时钟的关键代码. 今天就来实现一下. 步骤依然是先分析, 再上代码. 实现效果 View分析 时钟主要分为五个部分: 1.中心点: 圆心位置2.圆盘: 以中心点为圆心,drawCircle画个圆3.刻度: paint有个aip, setPathEffect可以根据path画特效, 那么刻度就可以根据圆的path画一个矩形path的特效, 并且这个api只会画特效, 不会画出圆. /** * shape: 特效的path, 这

  • Android自定义view实现滚动选择控件详解

    目录 前言 需求 编写代码 主要问题 前言 上篇文章通过一个有header和footer的滚动控件(Viewgroup)学了下MeasureSpec.onMeasure以及onLayout,接下来就用一个滚动选择的控件(View)来学一下onDraw的使用,并且了解下在XML自定义控件参数. 需求 这里就是一个滚动选择文字的控件,还是挺常见的,之前用别人的,现在选择手撕一个,核心思想如下: 1.有三层不同大小及透明度的选项,选中项放在中间 2.接受一个列表的数据,静态时显示三个值,滚动时显示四个

  • Android自定义View绘制贝塞尔曲线实现流程

    目录 前言 二阶贝塞尔曲线 三阶贝塞尔曲线 前言 对于Android开发,实现贝塞尔曲线还是比较方便的,有对应的API供你调用.由于一阶贝塞尔曲线就是一条直线,实际没啥多大用处,因此,下面主要讲解二阶和三阶. 二阶贝塞尔曲线 在Android中,使用quadTo来实现二阶贝塞尔 path.reset() path.moveTo(startX, startY) path.quadTo(currentX, currentY, endX, endY) canvas.drawPath(path, cur

  • Android开发使用自定义View将圆角矩形绘制在Canvas上的方法

    本文实例讲述了Android开发使用自定义View将圆角矩形绘制在Canvas上的方法.分享给大家供大家参考,具体如下: 前几天,公司一个项目中,头像图片需要添加圆角,这样UI效果会更好看,于是写了一个小的demo进行圆角的定义,该处主要是使用BitmapShader进行了渲染(如果要将一张图片裁剪成椭圆或圆形显示在屏幕上,也可以使用BitmapShader来完成). BitmapShader类完成渲染图片的基本步骤如下: 1.创建BitmapShader类的对象 /** * Call this

  • Android编程基于自定义View实现绚丽的圆形进度条功能示例

    本文实例讲述了Android编程基于自定义View实现绚丽的圆形进度条功能.分享给大家供大家参考,具体如下: 本文包含两个组件,首先上效果图: 1.ProgressBarView1(支持拖动): 2.ProgressBarView2(不同进度值显示不同颜色,不支持拖拽):   代码不多,注释也比较详细,全部贴上了: (一)ProgressBarView1: /** * 自定义绚丽的ProgressBar. */ public class ProgressBarView1 extends View

  • Android开发之自定义view实现通讯录列表A~Z字母提示效果【附demo源码下载】

    本文实例讲述了Android开发之自定义view实现通讯录列表A~Z字母提示效果.分享给大家供大家参考,具体如下: 开发工具:eclipse 运行环境:htc G9 android2.3.3 话不多说,先看效果图 其实左右边的A~Z是一个自定义的View,它直接覆盖在ListView上. MyLetterListView: public class MyLetterListView extends View { OnTouchingLetterChangedListener onTouching

  • android尺子的自定义view——RulerView详解

    项目中用到自定义尺子的样式: 原代码在github上找的,地址:https://github.com/QQabby/HorizontalRuler 原效果为 因为跟自己要使用的view稍有不同 所以做了一些修改,修改的注释都放在代码中了,特此记录一下. 首先是一个自定义View: public class RuleView extends View { private Paint paint; private Context context; private int maxValue = 500

  • Android 深入探究自定义view之流式布局FlowLayout的使用

    引子 文章开始前思考个问题,view到底是如何摆放到屏幕上的?在xml布局中,我们可能用到match_parent.wrap_content或是具体的值,那我们如何转为具体的dp?对于层层嵌套的布局,他们用的都不是具体的dp,我们又该如何确定它们的尺寸? 下图是实现效果 自定义View的流程 想想自定义view我们都要做哪些事情 布局,我们要确定view的尺寸以及要摆放的位置,也就是 onMeasure() .onLayout() 两方法 显示,布局之后是怎么把它显示出来,主要用的是onDraw

  • Android开发之自定义View(视图)用法详解

    本文实例讲述了Android开发之自定义View(视图)用法.分享给大家供大家参考,具体如下: View类是Android的一个超类,这个类几乎包含了所有的屏幕类型.每一个View都有一个用于绘图的画布,这个画布可以进行任意扩展.在游戏开发中往往需要自定义视图(View),这个画布的功能更能满足我们在游戏开发中的需要.在Android中,任何一个View类都只需重写onDraw 方法来实现界面显示,自定义的视图可以是复杂的3D实现,也可以是非常简单的文本形式等. 为了实现自定义View,需要创建

  • Android编程使用自定义View实现水波进度效果示例

    本文实例讲述了Android编程使用自定义View实现水波进度效果.分享给大家供大家参考,具体如下: 首先上效果图: 简介: 1.自动适应屏幕大小: 2.水波自动横向滚动: 3.各种绘制参数可通过修改常量进行控制. 代码不多,注释也比较详细,全部贴上: (一)自定义组件: /** * 水波进度效果. */ public class WaterWaveView extends View { //边框宽度 private int STROKE_WIDTH; //组件的宽,高 private int

  • Android开发使用自定义view实现ListView下拉的视差特效功能

    本文实例讲述了Android开发使用自定义view实现ListView下拉的视差特效功能.分享给大家供大家参考,具体如下: 一.概述: 现在流型的APP如微信朋友圈,QQ空间,微博个人展示都有视差特效的影子. 如图:下拉图片会产生图片拉升的效果,放手后图片有弹回到原处: 那我们如何实现呢? 1)重写ListView控件: 2)重写里面的overScrollBy方法 3)在松手后执行值动画 二.具体实现: 1.创建ParallaListView 自定义ListView public class P

  • Android编程基于自定义view实现公章效果示例【附源码下载】

    本文实例讲述了Android编程基于自定义view实现公章效果.分享给大家供大家参考,具体如下: 上次去一个公司面试,面试官问了一个题,怎么用android的自定义view实现一个公章的效果,据说这是华为之前的面试题,我想了下,要是公章的效果,最外层是一个圆,里面是一个五角星,但是这文字怎么画呢,比较难搞,后来回来看了下java的api,发现人家的Path里面本来就提供了这么一个方法: public void addArc(RectF oval, float startAngle, float

  • Android如何用自定义View实现雪花效果

    效果图 1.SnowView 类 package com.ilz.rocketapplication.handaccount.view; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.util.AttributeSet; import android.view.G

随机推荐