Java 类android.util.AttributeSet 实例源码

项目:poturnoChat    文件:SlidingTabStrip.java   
SlidingTabStrip(Context context, AttributeSet attrs) {
    super(context, attrs);
    setWillNotDraw(false);

    final float density = getResources().getDisplayMetrics().density;

    TypedValue outValue = new TypedValue();
    context.getTheme().resolveAttribute(android.R.attr.colorForeground, outValue, true);
    final int themeForegroundColor =  outValue.data;

    int defaultBottomBorderColor = setColorAlpha(themeForegroundColor,
            DEFAULT_BOTTOM_BORDER_COLOR_ALPHA);

    mDefaultTabColorizer = new SimpleTabColorizer();
    mDefaultTabColorizer.setIndicatorColors(DEFAULT_SELECTED_INDICATOR_COLOR);

    mBottomBorderThickness = (int) (DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS * density);
    mBottomBorderPaint = new Paint();
    mBottomBorderPaint.setColor(defaultBottomBorderColor);

    mSelectedIndicatorThickness = (int) (SELECTED_INDICATOR_THICKNESS_DIPS * density);
    mSelectedIndicatorPaint = new Paint();
}
项目:simple-keyboard    文件:KeyboardBuilder.java   
private KeyboardRow parseRowAttributes(final XmlPullParser parser)
        throws XmlPullParserException {
    final AttributeSet attr = Xml.asAttributeSet(parser);
    final TypedArray keyboardAttr = mResources.obtainAttributes(attr, R.styleable.Keyboard);
    try {
        if (keyboardAttr.hasValue(R.styleable.Keyboard_horizontalGap)) {
            throw new XmlParseUtils.IllegalAttribute(parser, TAG_ROW, "horizontalGap");
        }
        if (keyboardAttr.hasValue(R.styleable.Keyboard_verticalGap)) {
            throw new XmlParseUtils.IllegalAttribute(parser, TAG_ROW, "verticalGap");
        }
        return new KeyboardRow(mResources, mParams, parser, mCurrentY);
    } finally {
        keyboardAttr.recycle();
    }
}
项目:EyeShopping    文件:CameraBridgeViewBase.java   
public CameraBridgeViewBase(Context context, AttributeSet attrs) {
    super(context, attrs);

    int count = attrs.getAttributeCount();
    Log.d(TAG, "Attr count: " + Integer.valueOf(count));

    TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
    if (styledAttrs.getBoolean(R.styleable.CameraBridgeViewBase_show_fps, false))
        enableFpsMeter();

    mCameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);

    getHolder().addCallback(this);
    mMaxWidth = MAX_UNSPECIFIED;
    mMaxHeight = MAX_UNSPECIFIED;
    styledAttrs.recycle();
}
项目:MiPushFramework    文件:BottomNavigationItemView.java   
public BottomNavigationItemView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final Resources res = getResources();
    int inactiveLabelSize =
            res.getDimensionPixelSize(R.dimen.design_bottom_navigation_text_size);
    int activeLabelSize = res.getDimensionPixelSize(
            R.dimen.design_bottom_navigation_active_text_size);
    mDefaultMargin = res.getDimensionPixelSize(R.dimen.design_bottom_navigation_margin);
    mShiftAmount = inactiveLabelSize - activeLabelSize;
    mScaleUpFactor = 1f * activeLabelSize / inactiveLabelSize;
    mScaleDownFactor = 1f * inactiveLabelSize / activeLabelSize;

    LayoutInflater.from(context).inflate(R.layout.design_bottom_navigation_item, this, true);
    setBackgroundResource(R.drawable.design_bottom_navigation_item_background);
    mIcon = (ImageView) findViewById(R.id.icon);
    mSmallLabel = (TextView) findViewById(R.id.smallLabel);
    mLargeLabel = (TextView) findViewById(R.id.largeLabel);

}
项目:YMenuView    文件:YMenu.java   
private void initAttr(Context context, AttributeSet attrs) {
    TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.YMenuView, 0, 0);
    mYMenuButtonWidth = typedArray.getDimensionPixelSize(R.styleable.YMenuView_menuButtonWidth, mYMenuButtonWidth);
    mYMenuButtonHeight = typedArray.getDimensionPixelSize(R.styleable.YMenuView_menuButtonHeight, mYMenuButtonHeight);
    mYOptionButtonWidth = typedArray.getDimensionPixelSize(R.styleable.YMenuView_optionButtonWidth, mYOptionButtonWidth);
    mYOptionButtonHeight = typedArray.getDimensionPixelSize(R.styleable.YMenuView_optionButtonHeight, mYOptionButtonHeight);
    mYMenuToParentXMargin = typedArray.getDimensionPixelSize(R.styleable.YMenuView_menuToParentXMargin, mYMenuToParentXMargin);
    mYMenuToParentYMargin = typedArray.getDimensionPixelSize(R.styleable.YMenuView_menuToParentYMargin, mYMenuToParentYMargin);
    optionPositionCount = typedArray.getInteger(R.styleable.YMenuView_optionPositionCounts, optionPositionCount);
    optionColumns = typedArray.getInteger(R.styleable.YMenuView_optionColumns, optionColumns);
    mYOptionToParentYMargin = typedArray.getDimensionPixelSize(R.styleable.YMenuView_optionToParentYMargin, mYOptionToParentYMargin);
    mYOptionToParentXMargin = typedArray.getDimensionPixelSize(R.styleable.YMenuView_optionToParentXMargin, mYOptionToParentXMargin);
    mYOptionYMargin = typedArray.getDimensionPixelSize(R.styleable.YMenuView_optionYMargin, mYOptionYMargin);
    mYOptionXMargin = typedArray.getDimensionPixelSize(R.styleable.YMenuView_optionXMargin, mYOptionXMargin);
    mMenuButtonBackGroundId = typedArray.getResourceId(R.styleable.YMenuView_menuButtonBackGround, mMenuButtonBackGroundId);
    mOptionsBackGroundId = typedArray.getResourceId(R.styleable.YMenuView_optionsBackGround, R.drawable.null_drawable);
    mOptionSD_AnimationMode = typedArray.getInt(R.styleable.YMenuView_sd_animMode, mOptionSD_AnimationMode);
    mOptionSD_AnimationDuration = typedArray.getInt(R.styleable.YMenuView_sd_duration, mOptionSD_AnimationDuration);
    isShowMenu = typedArray.getBoolean(R.styleable.YMenuView_isShowMenu, isShowMenu);

    typedArray.recycle();
}
项目:QiangHongBao    文件:BorderCircleView.java   
private void init(Context context, AttributeSet attrs) {
    borderWidth = DisplayUtils.converDip2px(1);
    backgroundColor = Color.TRANSPARENT;
    borderColor = Color.BLACK;

    if (attrs != null) {
        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.BorderCircleView);
        borderWidth = ta.getDimensionPixelSize(R.styleable.BorderCircleView_borderWidth, borderWidth);
        backgroundColor = ta.getColor(R.styleable.BorderCircleView_backgroundColor, backgroundColor);
        borderColor = ta.getColor(R.styleable.BorderCircleView_borderCircleColor, borderColor);
        ta.recycle();
    }

    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.FILL);
    paint.setColor(backgroundColor);

    paintBorder = new Paint();
    paintBorder.setAntiAlias(true);
    paintBorder.setStyle(Paint.Style.STROKE);
    paintBorder.setColor(borderColor);

    setBackground(null);
}
项目:aftercare-app-android    文件:DCDashboardTeeth.java   
private void init(AttributeSet attributeSet) {
    inflate(getContext(), R.layout.view_dashboard_teeth, this);

    teeth = new DCTooth[32];
    for (int i = 0; i < 32; i++) {
        teeth[i] = (DCTooth) findViewById(getResources().getIdentifier("iv_t" + (i + 1), "id", getContext().getPackageName()));
    }

    hideAll();
}
项目:Spyglass    文件:TestDimensionHandlerCombinations.java   
@Test
@UiThreadTest
public void testSpyglassCallsMethod_attributeMissing_defaultToNullPresent() {
    final AttributeSet attrs = fromXml(context, R.xml.dimension_handler_without_attr);

    final DimensionHandlerTestTargetBase target = new WithDefaultToNull(context, attrs);

    assertThat(target.getReceivedValue(), is(ReceivedValue.<Integer>of(null)));
}
项目:boohee_v5.6    文件:ProgressIndicator.java   
public ProgressIndicator(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    this.mParams = new LayoutParams(-2, -2);
    this.cpIndicator = new CircleProgress(this, context);
    addView(this.cpIndicator);
    this.mParams.addRule(13);
    this.mParams.setMargins(24, 24, 24, 24);
}
项目:Muse-EEG-Toolkit    文件:EpochSurfaceView.java   
/** Creates a SurfaceView graph by parsing attributes. */
public EpochSurfaceView(Context context, AttributeSet attrs) {
  super(context, attrs);
  setWillNotDraw(false);

  int color = Color.BLACK;
  for (int i = 0; i < attrs.getAttributeCount(); i++) {
    if ("lineColor".equals(attrs.getAttributeName(i))) {
      color = Color.parseColor(attrs.getAttributeValue(i));
    }
  }
  this.color = color;
}
项目:simple-stack    文件:MessageView.java   
public MessageView(Context context, AttributeSet attrs) {
    super(context, attrs);
    setOrientation(VERTICAL);
    Utils.getComponent(context).inject(this);

    MessagePath screen = Backstack.getKey(context);
    message = conversations.get(screen.conversationIndex()).items.get(screen.messageId());
}
项目:UiLib    文件:EasySwitcher.java   
public EasySwitcher(Context context, AttributeSet attrs) {
    super(context, attrs);
    mContext = context;
    mAllItemArray = new ArrayList<>();
    mDefaultSelection = 0;
    initBaseView();
}
项目:materialExpansionPanel    文件:Expandable.java   
private void initAttrs(AttributeSet attrs) {
    if (attrs == null) return;

    TypedArray ta = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.Expandable, 0, 0);

    icon = ta.getDrawable(R.styleable.Expandable_exp_icon);
    iconStyle = ta.getInt(R.styleable.Expandable_exp_iconStyle, ExpandableUtils.ICON_STYLE_SQUARE);
    animateExpand = ta.getBoolean(R.styleable.Expandable_exp_animateExpand, false);
    backgroundColor = ta.getColor(R.styleable.Expandable_exp_backgroundColor, ContextCompat.getColor(getContext(), R.color.colorDefaultBackground));
    headerBackgroundColor = ta.getColor(R.styleable.Expandable_exp_headerBackgroundColor, ContextCompat.getColor(getContext(), R.color.colorDefaultBackground));
    expandIndicator = ta.getDrawable(R.styleable.Expandable_exp_expandIndicator);

    ta.recycle();
}
项目:chromium-for-android-56-debug-video    文件:TextScalePreference.java   
/**
 * Constructor for inflating from XML.
 */
public TextScalePreference(Context context, AttributeSet attrs) {
    super(context, attrs);

    mFontSizePrefs = FontSizePrefs.getInstance(getContext());

    setLayoutResource(R.layout.custom_preference);
    setWidgetLayoutResource(R.layout.preference_text_scale);
}
项目:firebase-testlab-instr-lib    文件:NoteEditor.java   
public LinedEditText(Context context, AttributeSet attrs) {
    super(context, attrs);

    mRect = new Rect();
    mPaint = new Paint();
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setColor(0x800000FF);
}
项目:QMark    文件:CornersFrameLayout.java   
public CornersFrameLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CornersFrameLayout, defStyle, 0);
    mCornersRadius = a.getDimensionPixelOffset(R.styleable.CornersFrameLayout_cornersRadius, 0);
    mAspectRatio = a.getFloat(R.styleable.CornersFrameLayout_cornersAspectRatio, 0);
    a.recycle();
    init();
}
项目:anyRTC-Meeting-Android    文件:CircleImageView.java   
public CircleImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView, defStyle, 0);

    mBorderWidth = a.getDimensionPixelSize(R.styleable.CircleImageView_civ_border_width, DEFAULT_BORDER_WIDTH);
    mBorderColor = a.getColor(R.styleable.CircleImageView_civ_border_color, DEFAULT_BORDER_COLOR);
    mBorderOverlay = a.getBoolean(R.styleable.CircleImageView_civ_border_overlay, DEFAULT_BORDER_OVERLAY);
    mFillColor = a.getColor(R.styleable.CircleImageView_civ_fill_color, DEFAULT_FILL_COLOR);

    a.recycle();

    init();
}
项目:Spyglass    文件:WithDefaultToDpDimensionResource.java   
private void init(final AttributeSet attrs, final int defStyleAttr, final int defStyleRes) {
    WithDefaultToDpDimensionResource_SpyglassCompanion
            .builder()
            .withTarget(this)
            .withContext(getContext())
            .withStyleableResource(R.styleable.DimensionHandlerTestTargetBase)
            .withAttributeSet(attrs)
            .withDefaultStyleAttribute(defStyleAttr)
            .withDefaultStyleResource(defStyleRes)
            .build()
            .passDataToMethods();
}
项目:iosched-reader    文件:BezelImageView.java   
public BezelImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Attribute initialization.
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BezelImageView,
            defStyle, 0);

    mMaskDrawable = a.getDrawable(R.styleable.BezelImageView_maskDrawable);
    if (mMaskDrawable != null) {
        mMaskDrawable.setCallback(this);
    }

    mBorderDrawable = a.getDrawable(R.styleable.BezelImageView_borderDrawable);
    if (mBorderDrawable != null) {
        mBorderDrawable.setCallback(this);
    }

    mDesaturateOnPress = a.getBoolean(R.styleable.BezelImageView_desaturateOnPress,
            mDesaturateOnPress);

    a.recycle();

    // Other initialization.
    mBlackPaint = new Paint();
    mBlackPaint.setColor(0xff000000);

    mMaskedPaint = new Paint();
    mMaskedPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));

    // Always want a cache allocated.
    mCacheBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);

    if (mDesaturateOnPress) {
        // Create a desaturate color filter for pressed state.
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0);
        mDesaturateColorFilter = new ColorMatrixColorFilter(cm);
    }
}
项目:boohee_v5.6    文件:DietShareEatItem.java   
public DietShareEatItem(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mItem.put("breakfast", Integer.valueOf(R.drawable.pr));
    mItem.put("lunch", Integer.valueOf(R.drawable.pt));
    mItem.put("dinner", Integer.valueOf(R.drawable.ps));
    mItem.put(SNACK, Integer.valueOf(R.drawable.pq));
    mItem.put("sport", Integer.valueOf(R.drawable.pu));
    this.mView = LayoutInflater.from(getContext()).inflate(R.layout.os, null);
    addView(this.mView);
    ButterKnife.inject((View) this);
}
项目:AssistantBySDK    文件:LoginoutButton.java   
/**
 * 初始化函数。
 * 
 * @param context 上下文环境,一般为放置该 Button 的 Activity 
 * @param attrs   XML 属性集合对象
 */
private void initialize(Context context, AttributeSet attrs) {
    mContext = context;
    this.setOnClickListener(this);

    // 如果布局文件中未设置 style,加载默认的 style
    loadDefaultStyle(attrs);
}
项目:LongImageCamera    文件:CameraView.java   
@SuppressWarnings("WrongConstant")
public CameraView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    if (isInEditMode()){
        mCallbacks = null;
        mDisplayOrientationDetector = null;
        return;
    }
    // Internal setup
    final PreviewImpl preview = createPreviewImpl(context);
    mCallbacks = new CallbackBridge();
    if (Build.VERSION.SDK_INT < 21) {
        mImpl = new Camera1(mCallbacks, preview);
    } else if (Build.VERSION.SDK_INT < 23) {
        mImpl = new Camera2(mCallbacks, preview, context);
    } else {
        mImpl = new Camera2Api23(mCallbacks, preview, context);
    }
    // Attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CameraView, defStyleAttr,
            R.style.Widget_CameraView);
    mAdjustViewBounds = a.getBoolean(R.styleable.CameraView_android_adjustViewBounds, false);
    setFacing(a.getInt(R.styleable.CameraView_facing, FACING_BACK));
    String aspectRatio = a.getString(R.styleable.CameraView_aspectRatio);
    if (aspectRatio != null) {
        setAspectRatio(AspectRatio.parse(aspectRatio));
    } else {
        setAspectRatio(Constants.DEFAULT_ASPECT_RATIO);
    }
    setAutoFocus(a.getBoolean(R.styleable.CameraView_autoFocus, true));
    setFlash(a.getInt(R.styleable.CameraView_flash, Constants.FLASH_AUTO));
    a.recycle();
    // Display orientation detector
    mDisplayOrientationDetector = new DisplayOrientationDetector(context) {
        @Override
        public void onDisplayOrientationChanged(int displayOrientation) {
            mImpl.setDisplayOrientation(displayOrientation);
        }
    };
}
项目:DizzyPassword    文件:PswInputView.java   
/**
     * 初始化相关参数
     */
    void init(AttributeSet attrs) {
        final float dp = getResources().getDisplayMetrics().density;
        this.setFocusable(true);
        this.setFocusableInTouchMode(true);
        input = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        result = new ArrayList<>();
        if (attrs != null) {
            TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.PswInputView);
//            mBorderColor = ta.getColor(R.styleable.PswInputView_border_color, getResources().getColor(R.color.color_13));
            mBorderColor = ta.getColor(R.styleable.PswInputView_border_color, ThemeUtils.getPrimaryColor(AppManager.getAppManager().currentActivity()));
            mDotColor = ta.getColor(R.styleable.PswInputView_dot_color, getResources().getColor(R.color.color_bg));
            count = ta.getInt(R.styleable.PswInputView_count, 6);
            ta.recycle();
        } else {
            mBorderColor = Color.LTGRAY;
            mDotColor = Color.GRAY;
            count = 6;//默认6位密码
        }
        size = (int) (dp * 30);//默认30dp一格
        //color
        mBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mBorderPaint.setStrokeWidth(2);
        mBorderPaint.setStyle(Paint.Style.STROKE);
        mBorderPaint.setColor(mBorderColor);
        mDotPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mDotPaint.setStrokeWidth(3);
        mDotPaint.setStyle(Paint.Style.FILL);
        mDotPaint.setColor(mDotColor);
        mRoundRect = new RectF();
        mRoundRadius = (int) (5 * dp);
        mFocusLineLength = 0;
        this.setOnKeyListener(new MyKeyListener());
    }
项目:SnappyRecyclerView    文件:SnappingRecyclerView.java   
public SnappingRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    initialise(context, attrs);
}
项目:PreviewSeekBar    文件:PreviewGeneralLayout.java   
public PreviewGeneralLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    init(context, attrs);
}
项目:TrendChartView    文件:TrendChartView.java   
private void init(Context context, AttributeSet attrs) {
    initPaint();
}
项目:Cluttr    文件:SquareFrameLayout.java   
public SquareFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
}
项目:Idea-ijkplayer    文件:TimeBarView.java   
public TimeBarView(Context context, AttributeSet attrs) {
    this(context, attrs,0);
}
项目:CXJPadProject    文件:DishesView.java   
private DishesView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final TypedArray a= context.obtainStyledAttributes(attrs,R.styleable.dishesStyleable);
    updateBackgroundFromTypedArray(a);
    a.recycle();
}
项目:Hands-On-Android-UI-Development    文件:ColorizedCardView.java   
public ColorizedCardView(
        final Context context,
        final AttributeSet attrs,
        final int defStyleAttr) {
    super(context, attrs, defStyleAttr);
}
项目:CustomListView    文件:PullToRefreshBase.java   
public PullToRefreshBase(Context context, AttributeSet attrs) {
    super(context, attrs);
    init(context, attrs);
}
项目:YCUtils    文件:MaterialRippleLayout.java   
public MaterialRippleLayout(Context context, AttributeSet attrs) {
    this(context, attrs, 0);
}
项目:FontUtils    文件:FontTextView.java   
public FontTextView(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    init(context,attrs);
}
项目:qmui    文件:QMUICollapsingTopBarLayout.java   
public QMUICollapsingTopBarLayout(Context context, AttributeSet attrs) {
    this(context, attrs, 0);
}
项目:recyclviewpagger    文件:MetalRecyclerViewPager.java   
public MetalRecyclerViewPager(Context context, @Nullable AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    init(context, attrs);
}
项目:ImageFrame    文件:ImageFrameView.java   
public ImageFrameView(Context context, @Nullable AttributeSet attrs) {
  super(context, attrs);
  init();
}
项目:pipe    文件:SquareLayout.java   
public SquareLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
}
项目:JBase    文件:CustomViewPager.java   
public CustomViewPager(Context context, AttributeSet attrs) {
    super(context, attrs);
}
项目:DailyStudy    文件:SlideLayout.java   
public SlideLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    init(context);
}
项目:GitHub    文件:EmptyRecyclerView.java   
public EmptyRecyclerView(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
}