a
554325746@qq.com
2019-12-25 603cb36a5123e46656b06a5deb8d7ac7ff81307f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.basic.security.widget;
 
import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.TextView;
 
public class CircleTextView extends TextView {
    public CircleTextView(Context context) {
        super(context);
    }
 
    public CircleTextView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initView(attrs);
    }
 
    public CircleTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(attrs);
    }
 
    public CircleTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        initView(attrs);
    }
 
    public void setMeasuredDimension1(int measuredWidth, int measuredHeight) {
        setMeasuredDimension(measuredWidth, measuredHeight);
    }
 
    public void initView(AttributeSet attrs) {
//        for (int i = 0; i < attrs.getAttributeCount(); i++) {
//            String value = attrs.getAttributeValue(i);
//            String name = attrs.getAttributeName(i);
//            if (value.startsWith("@")) {
//                value = value.substring(1);
//                String resourceName = BaseApplication.getApplication().activity.getResources().getResourceName(Integer.parseInt(value));
//                System1.out.println("CircleTextView.initView " + name + "=" + resourceName);
//            }
//        }
    }
 
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        if (getHeight() > 0 && getWidth() > 0 && getHeight() > getWidth()) {
            setWidth(getHeight());
        }
    }
 
    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
    }
}