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(); }
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(); } }
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(); }
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); }
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(); }
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); }
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(); }
@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))); }
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); }
/** 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; }
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()); }
public EasySwitcher(Context context, AttributeSet attrs) { super(context, attrs); mContext = context; mAllItemArray = new ArrayList<>(); mDefaultSelection = 0; initBaseView(); }
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(); }
/** * 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); }
public LinedEditText(Context context, AttributeSet attrs) { super(context, attrs); mRect = new Rect(); mPaint = new Paint(); mPaint.setStyle(Paint.Style.STROKE); mPaint.setColor(0x800000FF); }
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(); }
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(); }
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(); }
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); } }
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); }
/** * 初始化函数。 * * @param context 上下文环境,一般为放置该 Button 的 Activity * @param attrs XML 属性集合对象 */ private void initialize(Context context, AttributeSet attrs) { mContext = context; this.setOnClickListener(this); // 如果布局文件中未设置 style,加载默认的 style loadDefaultStyle(attrs); }
@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); } }; }
/** * 初始化相关参数 */ 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()); }
public SnappingRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); initialise(context, attrs); }
public PreviewGeneralLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(context, attrs); }
private void init(Context context, AttributeSet attrs) { initPaint(); }
public SquareFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
public TimeBarView(Context context, AttributeSet attrs) { this(context, attrs,0); }
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(); }
public ColorizedCardView( final Context context, final AttributeSet attrs, final int defStyleAttr) { super(context, attrs, defStyleAttr); }
public PullToRefreshBase(Context context, AttributeSet attrs) { super(context, attrs); init(context, attrs); }
public MaterialRippleLayout(Context context, AttributeSet attrs) { this(context, attrs, 0); }
public FontTextView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); init(context,attrs); }
public QMUICollapsingTopBarLayout(Context context, AttributeSet attrs) { this(context, attrs, 0); }
public MetalRecyclerViewPager(Context context, @Nullable AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(context, attrs); }
public ImageFrameView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); init(); }
public SquareLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
public CustomViewPager(Context context, AttributeSet attrs) { super(context, attrs); }
public SlideLayout(@NonNull Context context, @Nullable AttributeSet attrs) { super(context, attrs); init(context); }
public EmptyRecyclerView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); }