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: 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 #2
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 #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: 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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
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 #13
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 #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: 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 #16
Source File: TitleBar.java    From titlebar with Apache License 2.0 4 votes vote down vote up
public TitleBar(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    init(context);
}
 
Example #17
Source File: TimeLineAvatarImageView.java    From iBeebo with GNU General Public License v3.0 4 votes vote down vote up
public TimeLineAvatarImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    initLayout(context);
}
 
Example #18
Source File: SkbContainer.java    From Android-tv-widget with Apache License 2.0 4 votes vote down vote up
public SkbContainer(Context context, AttributeSet attrs) {
	super(context, attrs);
	init(context, attrs);
}
 
Example #19
Source File: DividerItemDecoration.java    From BlueBoard with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("UnusedDeclaration")
public DividerItemDecoration(Context context, AttributeSet attrs) {
    final TypedArray a = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.listDivider});
    setDivider(a.getDrawable(0));
    a.recycle();
}
 
Example #20
Source File: ClickLinearLayout.java    From Ticket-Analysis with MIT License 4 votes vote down vote up
public ClickLinearLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
}
 
Example #21
Source File: CompatTextView.java    From FireFiles with Apache License 2.0 4 votes vote down vote up
public CompatTextView(Context context, AttributeSet attrs, int defStyleAttr) {
	super(context, attrs, defStyleAttr);
	init(attrs);
}
 
Example #22
Source File: ReflectItemView.java    From Android-tv-widget with Apache License 2.0 4 votes vote down vote up
public ReflectItemView(Context context, AttributeSet attrs) {
    this(context, attrs, 0);
}
 
Example #23
Source File: RenderingStatistics.java    From retroband with Apache License 2.0 4 votes vote down vote up
public RenderingStatistics(Context context,AttributeSet attrs,int defStyle) {
	super(context,attrs,defStyle);
}
 
Example #24
Source File: PagerSlidingTabStrip.java    From prayer-times-android with Apache License 2.0 4 votes vote down vote up
public PagerSlidingTabStrip(@NonNull Context context, AttributeSet attrs) {
    this(context, attrs, 0);
}
 
Example #25
Source File: AppMenuItemIcon.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
public AppMenuItemIcon(Context context, AttributeSet attrs) {
    super(context, attrs);
}
 
Example #26
Source File: SmartTabLayout2.java    From RecyclerPager with Apache License 2.0 4 votes vote down vote up
public SmartTabLayout2(Context context, AttributeSet attrs) {
    super(context, attrs);
}
 
Example #27
Source File: CheckableRelativeLayout.java    From Android-Next with Apache License 2.0 4 votes vote down vote up
public CheckableRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
}
 
Example #28
Source File: IjkVideoView.java    From MD with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public IjkVideoView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    initVideoView(context);
}
 
Example #29
Source File: TimelineView.java    From DatePickerTimeline with Apache License 2.0 4 votes vote down vote up
public TimelineView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    init();
}
 
Example #30
Source File: EmojiAsyncLoadTextView.java    From aurora-imui with MIT License 4 votes vote down vote up
public EmojiAsyncLoadTextView(Context context, AttributeSet attrs) {
    this(context, attrs, 0);
}