Java Code Examples for android.util.AttributeSet

The following examples show how to use android.util.AttributeSet. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public InfiniteCycleManager(
        final Context context,
        final ViewPageable viewPageable,
        final AttributeSet attributeSet
) {
    mContext = context;
    mIsVertical = viewPageable instanceof VerticalViewPager;

    mViewPageable = viewPageable;
    mCastViewPageable = (View) viewPageable;

    // Set default InfiniteViewPager
    mViewPageable.setPageTransformer(false, getInfinityCyclePageTransformer());
    mViewPageable.addOnPageChangeListener(mInfinityCyclePageChangeListener);
    mViewPageable.setClipChildren(DEFAULT_DISABLE_FLAG);
    mViewPageable.setDrawingCacheEnabled(DEFAULT_DISABLE_FLAG);
    mViewPageable.setWillNotCacheDrawing(DEFAULT_ENABLE_FLAG);
    mViewPageable.setPageMargin(DEFAULT_PAGE_MARGIN);
    mViewPageable.setOffscreenPageLimit(DEFAULT_OFFSCREEN_PAGE_LIMIT);
    mViewPageable.setOverScrollMode(OVER_SCROLL_NEVER);

    // Reset scroller and process attribute set
    resetScroller();
    processAttributeSet(attributeSet);
}
 
Example 2
Source Project: letv   Source File: JazzyViewPager.java    License: Apache License 2.0 6 votes vote down vote up
public JazzyViewPager(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.mEnabled = true;
    this.mFadeEnabled = false;
    this.mOutlineEnabled = false;
    this.mEffect = TransitionEffect.Standard;
    this.mObjs = new LinkedHashMap();
    this.jvpInnerHandler = null;
    this.mMatrix = new Matrix();
    this.mCamera = new Camera();
    this.mTempFloat2 = new float[2];
    setClipChildren(false);
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.JazzyViewPager);
    setTransitionEffect(TransitionEffect.valueOf(getResources().getStringArray(R.array.jazzy_effects)[ta.getInt(0, 0)]));
    setFadeEnabled(ta.getBoolean(1, false));
    setOutlineEnabled(ta.getBoolean(2, false));
    setOutlineColor(ta.getColor(3, -1));
    switch (1.$SwitchMap$com$letv$android$client$widget$JazzyViewPager$TransitionEffect[this.mEffect.ordinal()]) {
        case 1:
        case 2:
            setFadeEnabled(true);
            break;
    }
    ta.recycle();
}
 
Example 3
Source Project: PlayTogether   Source File: AutoLayoutActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(String name, Context context, AttributeSet attrs)
{
	View view = null;
	if (name.equals(LAYOUT_FRAMELAYOUT))
	{
		view = new AutoFrameLayout(context, attrs);
	}
	if (name.equals(LAYOUT_LINEARLAYOUT))
	{
		view = new AutoLinearLayout(context, attrs);
	}
	if (name.equals(LAYOUT_RELATIVELAYOUT))
	{
		view = new AutoRelativeLayout(context, attrs);
	}
	if (name.equals(CARD_VIEW))
	{
		view = new AutoCardView(context, attrs);
	}
	if (view != null) return view;
	return super.onCreateView(name, context, attrs);
}
 
Example 4
Source Project: material-components-android   Source File: SwitchRowView.java    License: Apache License 2.0 6 votes vote down vote up
public SwitchRowView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
  super(context, attrs, defStyleAttr);

  TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwitchRowView);

  CharSequence title = a.getText(R.styleable.SwitchRowView_title);
  subtitle = a.getText(R.styleable.SwitchRowView_subtitle);
  subtitleOn = a.getText(R.styleable.SwitchRowView_subtitleOn);
  subtitleOff = a.getText(R.styleable.SwitchRowView_subtitleOff);

  a.recycle();

  LayoutInflater.from(context).inflate(R.layout.switch_row_view, this);
  titleView = findViewById(R.id.switch_row_title);
  subtitleView = findViewById(R.id.switch_row_subtitle);
  switchMaterial = findViewById(R.id.switch_row_switch);

  titleView.setText(title);
  updateSubtitle();
  switchMaterial.setOnCheckedChangeListener((buttonView, isChecked) -> updateSubtitle());
}
 
Example 5
Source Project: PopupCircleMenu   Source File: PopupCircleView.java    License: MIT License 6 votes vote down vote up
public PopupCircleView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mContext = (Activity) context;
    mHandler = new Handler(Looper.getMainLooper(), this);

    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CircleMenu, 0, 0);
    initDefaultParam();

    mRadius = a.getDimensionPixelSize(R.styleable.CircleMenu_pc_radius, (int) TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_SP, 100, getResources().getDisplayMetrics()));
    mAnimDuration = a.getInt(R.styleable.CircleMenu_pc_anim_duration, 250);
    mOpenDirection = a.getInt(R.styleable.CircleMenu_pc_open_direction, UNDEFIEN);

    a.recycle();
    init();

}
 
Example 6
@Override
protected final GridView createRefreshableView(Context context, AttributeSet attrs) {
	final GridView gv;
	if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
		gv = new InternalGridViewSDK9(context, attrs);
	} else {
		gv = new InternalGridView(context, attrs);
	}

	// Use Generated ID (from res/values/ids.xml)
	gv.setId(R.id.gridview);
	return gv;
}
 
Example 7
Source Project: barterli_android   Source File: CirclePageIndicator.java    License: Apache License 2.0 5 votes vote down vote up
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) return;

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke.setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

    Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
    if (background != null) {
      setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}
 
Example 8
Source Project: Viewer   Source File: ToggleButton.java    License: Apache License 2.0 5 votes vote down vote up
public void setup(AttributeSet attrs) {
	paint = new Paint(Paint.ANTI_ALIAS_FLAG);
	paint.setStyle(Style.FILL);
	paint.setStrokeCap(Cap.ROUND);
	
	springSystem = SpringSystem.create();
	spring = springSystem.createSpring();
	spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(50, 7));
	
	this.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View arg0) {
			toggle(defaultAnimate);
		}
	});
	
	TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ToggleButton);
	offBorderColor = typedArray.getColor(R.styleable.ToggleButton_offBorderColor, offBorderColor);
	onColor = typedArray.getColor(R.styleable.ToggleButton_onColor, onColor);
	spotColor = typedArray.getColor(R.styleable.ToggleButton_spotColor, spotColor);
	offColor = typedArray.getColor(R.styleable.ToggleButton_offColor, offColor);
	borderWidth = typedArray.getDimensionPixelSize(R.styleable.ToggleButton_borderWidth1, borderWidth);
	defaultAnimate = typedArray.getBoolean(R.styleable.ToggleButton_animate, defaultAnimate);
	isDefaultOn = typedArray.getBoolean(R.styleable.ToggleButton_isDefaultOn, isDefaultOn);
	typedArray.recycle();
	
	borderColor = offBorderColor;

	if (isDefaultOn) {
		toggleOn();
	}
}
 
Example 9
public CallSliderAnswer(
        Context context,
        AttributeSet attrs,
        int defStyle
) {
    super(context, attrs, defStyle);
    LayoutInflater.from(getContext()).inflate(R.layout.call_slider_answer, this, true);
    mCallImage = findViewById(R.id.call_slider_img);
    if (mCallImage != null) {
        mCallImage.setOnTouchListener(this);
    }
    mCallText = findViewById(R.id.call_slider_text);
}
 
Example 10
@SuppressLint("JavascriptInterface")
@Override
protected WebView createRefreshableView(Context context, AttributeSet attrs) {
	WebView webView = super.createRefreshableView(context, attrs);

	// Need to add JS Interface so we can get the response back
	mJsCallback = new JsValueCallback();
	webView.addJavascriptInterface(mJsCallback, JS_INTERFACE_PKG);

	return webView;
}
 
Example 11
Source Project: hkm-progress-button   Source File: FlatButton.java    License: MIT License 5 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    mNormalDrawable = new StateListDrawable();
    if (attrs != null) {
        initAttributes(context, attrs);
    }
    mNormalText = getText().toString();
    setBackgroundCompat(mNormalDrawable);
    getFont(context);
}
 
Example 12
Source Project: PhotoEdit   Source File: DrawingBoardView.java    License: Apache License 2.0 5 votes vote down vote up
public DrawingBoardView(Context context, AttributeSet attributeSet)
{
	super(context, attributeSet);
	this.context = context;
	brushGestureListener = new BrushGestureListener();
	brushGestureDetector = new GestureDetector(context,
			brushGestureListener);

}
 
Example 13
public KeyboardAwareLinearLayout(Context context, AttributeSet attrs, int defStyle) {
  super(context, attrs, defStyle);
  final int statusBarRes = getResources().getIdentifier("status_bar_height", "dimen", "android");
  minKeyboardSize            = getResources().getDimensionPixelSize(R.dimen.min_keyboard_size);
  minCustomKeyboardSize      = getResources().getDimensionPixelSize(R.dimen.min_custom_keyboard_size);
  defaultCustomKeyboardSize  = getResources().getDimensionPixelSize(R.dimen.default_custom_keyboard_size);
  minCustomKeyboardTopMargin = getResources().getDimensionPixelSize(R.dimen.min_custom_keyboard_top_margin);
  statusBarHeight            = statusBarRes > 0 ? getResources().getDimensionPixelSize(statusBarRes) : 0;
  viewInset                  = getViewInset();
}
 
Example 14
Source Project: android-RibbonViews   Source File: RibbonTag.java    License: MIT License 5 votes vote down vote up
private void getAttrs(AttributeSet attributeSet) {
    TypedArray typedArray = getContext().obtainStyledAttributes(attributeSet, R.styleable.RibbonTag);
    try {
        setTypeArray(typedArray);
    } finally {
        typedArray.recycle();
    }
}
 
Example 15
Source Project: ProjectX   Source File: ClipImageView.java    License: Apache License 2.0 5 votes vote down vote up
private void initView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    final TypedArray custom = context.obtainStyledAttributes(attrs, R.styleable.ClipImageView,
            defStyleAttr, defStyleRes);
    final int type = custom.getInt(R.styleable.ClipImageView_civClipType, 0);
    final float radius = custom.getDimension(R.styleable.ClipImageView_civRoundRectRadius,
            0);
    final float width = custom.getDimension(R.styleable.ClipImageView_civBorderWidth,
            0);
    final ColorStateList color = custom.getColorStateList(
            R.styleable.ClipImageView_civBorderColor);
    final String name = custom.getString(R.styleable.ClipImageView_civClipOutlineProvider);
    custom.recycle();
    mClipPath.setFillType(Path.FillType.EVEN_ODD);
    mOutlinePath.setFillType(Path.FillType.EVEN_ODD);
    switch (type) {
        default:
            break;
        case 1:
            mProvider = ClipOutlineProvider.CIRCLE;
            break;
        case 2:
            mProvider = ClipOutlineProvider.OVAL;
            break;
        case 3:
            mProvider = ClipOutlineProvider.FULL_ROUND_RECT;
            break;
        case 4:
            mProvider = new RoundRectClipOutlineProvider(radius);
            break;
    }
    final ClipOutlineProvider provider = ConstructorHelper.newInstance(context, name,
            isInEditMode(), this, ClipOutlineProvider.class,
            attrs, defStyleAttr, defStyleRes);
    if (provider != null)
        mProvider = provider;
    mBorderWidth = width;
    mBorderColor = color;
}
 
Example 16
Source Project: FirefoxReality   Source File: LinkTextView.java    License: Mozilla Public License 2.0 4 votes vote down vote up
public LinkTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
}
 
Example 17
Source Project: fingerpoetry-android   Source File: DragItemRecyclerView.java    License: Apache License 2.0 4 votes vote down vote up
public DragItemRecyclerView(Context context, AttributeSet attrs) {
    super(context, attrs, 0);
    init();
}
 
Example 18
Source Project: DevUtils   Source File: SignView.java    License: Apache License 2.0 4 votes vote down vote up
public SignView(Context context, AttributeSet attrs) {
    super(context, attrs);
}
 
Example 19
Source Project: ClassifyView   Source File: LinearHHClassifyView.java    License: Apache License 2.0 4 votes vote down vote up
public LinearHHClassifyView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
}
 
Example 20
Source Project: giffun   Source File: PhotoView.java    License: Apache License 2.0 4 votes vote down vote up
public PhotoView(Context context, AttributeSet attr) {
    this(context, attr, 0);
}
 
Example 21
Source Project: AlarmOn   Source File: TimeEditText.java    License: Apache License 2.0 4 votes vote down vote up
public TimeEditText(Context context, AttributeSet attrs) {
    super(context, attrs);
}
 
Example 22
Source Project: bither-android   Source File: OverScrollableListView.java    License: Apache License 2.0 4 votes vote down vote up
public OverScrollableListView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setOverScrollMode(OVER_SCROLL_ALWAYS);
}
 
Example 23
public SwipeableRecyclerView(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs, 0);
}
 
Example 24
Source Project: Paralloid   Source File: ParallaxHorizontalScrollView.java    License: Apache License 2.0 4 votes vote down vote up
public ParallaxHorizontalScrollView(Context context, AttributeSet attrs) {
    super(context, attrs);
    init();
}
 
Example 25
Source Project: FireFiles   Source File: ColorPreference.java    License: Apache License 2.0 4 votes vote down vote up
public ColorPreference(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    initAttrs(attrs, defStyle);
}
 
Example 26
Source Project: android-PictureInPicture   Source File: MovieView.java    License: Apache License 2.0 4 votes vote down vote up
public MovieView(Context context, AttributeSet attrs) {
    this(context, attrs, 0);
}
 
Example 27
Source Project: renrenpay-android   Source File: IconTextView.java    License: Apache License 2.0 4 votes vote down vote up
public IconTextView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    // TODO Auto-generated constructor stub
    this.setTypeface(Typeface.createFromAsset(context.getAssets(), "iconfont.ttf"));
}
 
Example 28
Source Project: BaiduMap-TrafficAssistant   Source File: ArcMenu.java    License: MIT License 4 votes vote down vote up
public ArcMenu(Context context, AttributeSet attrs, int defStyle) {
	super(context, attrs, defStyle);

	mRadius = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
			100, getResources().getDisplayMetrics());

	// 获取自定义属性的值;

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

	int pos = a.getInt(R.styleable.ArcMenu_position, POS_RIGHT_BOTTOM);

	switch (pos) {
	case POS_LEFT_TOP:
		mPosition = Position.LEFT_TOP;

		break;
	case POS_LEFT_BOTTOM:
		mPosition = Position.LEFT_BOTTOM;

		break;
	case POS_RIGHT_TOP:
		mPosition = Position.RIGHT_TOP;

		break;
	case POS_RIGHT_BOTTOM:
		mPosition = Position.RIGHT_BOTTOM;

		break;

	}

	mRadius = (int) a.getDimension(R.styleable.ArcMenu_radius, TypedValue
			.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100,
					getResources().getDisplayMetrics()));

	// Log.i("TAG", "position=" + mPosition + ",radius=" + mRadius);

	a.recycle();
}
 
Example 29
@NonNull
@Override
protected AppCompatCheckBox createCheckBox(Context context, AttributeSet attrs) {
  return new MaterialCheckBox(context, attrs);
}
 
Example 30
Source Project: android-common-utils   Source File: BadgeView.java    License: Apache License 2.0 4 votes vote down vote up
public BadgeView(Context context, AttributeSet attrs, int defStyle) {
	this(context, attrs, defStyle, null, 0);
}