android.util.AttributeSet Java Examples

The following examples show how to use android.util.AttributeSet. 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
Source File: InfiniteCycleManager.java    From InfiniteCycleViewPager with Apache License 2.0 6 votes vote down vote up
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 File: JazzyViewPager.java    From letv with 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 File: AutoLayoutActivity.java    From PlayTogether with 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 File: SwitchRowView.java    From material-components-android with 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 File: PopupCircleView.java    From PopupCircleMenu with 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
Source File: PullToRefreshGridView.java    From NetEasyNews with GNU General Public License v3.0 5 votes vote down vote up
@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 File: CirclePageIndicator.java    From barterli_android with 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 File: ToggleButton.java    From Viewer with 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
Source File: CallSliderAnswer.java    From toktok-android with GNU General Public License v3.0 5 votes vote down vote up
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
Source File: PullToRefreshWebView2.java    From Alibaba-Android-Certification with MIT License 5 votes vote down vote up
@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 File: FlatButton.java    From hkm-progress-button with 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 File: DrawingBoardView.java    From PhotoEdit with 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
Source File: KeyboardAwareLinearLayout.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
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 File: RibbonTag.java    From android-RibbonViews with 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 File: ClipImageView.java    From ProjectX with 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 File: LinkTextView.java    From FirefoxReality with 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 File: DragItemRecyclerView.java    From fingerpoetry-android with Apache License 2.0 4 votes vote down vote up
public DragItemRecyclerView(Context context, AttributeSet attrs) {
    super(context, attrs, 0);
    init();
}
 
Example #18
Source File: SignView.java    From DevUtils with Apache License 2.0 4 votes vote down vote up
public SignView(Context context, AttributeSet attrs) {
    super(context, attrs);
}
 
Example #19
Source File: LinearHHClassifyView.java    From ClassifyView with 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 File: PhotoView.java    From giffun with Apache License 2.0 4 votes vote down vote up
public PhotoView(Context context, AttributeSet attr) {
    this(context, attr, 0);
}
 
Example #21
Source File: TimeEditText.java    From AlarmOn with Apache License 2.0 4 votes vote down vote up
public TimeEditText(Context context, AttributeSet attrs) {
    super(context, attrs);
}
 
Example #22
Source File: OverScrollableListView.java    From bither-android with 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
Source File: SwipeableRecyclerView.java    From AndroidSwipeToDelete with Apache License 2.0 4 votes vote down vote up
public SwipeableRecyclerView(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs, 0);
}
 
Example #24
Source File: ParallaxHorizontalScrollView.java    From Paralloid with Apache License 2.0 4 votes vote down vote up
public ParallaxHorizontalScrollView(Context context, AttributeSet attrs) {
    super(context, attrs);
    init();
}
 
Example #25
Source File: ColorPreference.java    From FireFiles with 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 File: MovieView.java    From android-PictureInPicture with Apache License 2.0 4 votes vote down vote up
public MovieView(Context context, AttributeSet attrs) {
    this(context, attrs, 0);
}
 
Example #27
Source File: IconTextView.java    From renrenpay-android with 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 File: ArcMenu.java    From BaiduMap-TrafficAssistant with 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
Source File: MaterialComponentsViewInflater.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
@NonNull
@Override
protected AppCompatCheckBox createCheckBox(Context context, AttributeSet attrs) {
  return new MaterialCheckBox(context, attrs);
}
 
Example #30
Source File: BadgeView.java    From android-common-utils with Apache License 2.0 4 votes vote down vote up
public BadgeView(Context context, AttributeSet attrs, int defStyle) {
	this(context, attrs, defStyle, null, 0);
}