本文整理汇总了Java中android.util.AttributeSet类的典型用法代码示例。如果您正苦于以下问题:Java AttributeSet类的具体用法?Java AttributeSet怎么用?Java AttributeSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttributeSet类属于android.util包,在下文中一共展示了AttributeSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSpyglassCallsMethod_attributeMissing_defaultToNullPresent
import android.util.AttributeSet; //导入依赖的package包/类
@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)));
}
示例2: SlidingTabStrip
import android.util.AttributeSet; //导入依赖的package包/类
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();
}
示例3: parseRowAttributes
import android.util.AttributeSet; //导入依赖的package包/类
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();
}
}
示例4: CameraBridgeViewBase
import android.util.AttributeSet; //导入依赖的package包/类
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();
}
示例5: BottomNavigationItemView
import android.util.AttributeSet; //导入依赖的package包/类
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);
}
示例6: initAttr
import android.util.AttributeSet; //导入依赖的package包/类
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();
}
示例7: init
import android.util.AttributeSet; //导入依赖的package包/类
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);
}
示例8: init
import android.util.AttributeSet; //导入依赖的package包/类
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();
}
示例9: ProgressIndicator
import android.util.AttributeSet; //导入依赖的package包/类
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);
}
示例10: EpochSurfaceView
import android.util.AttributeSet; //导入依赖的package包/类
/** 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;
}
示例11: MessageView
import android.util.AttributeSet; //导入依赖的package包/类
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());
}
示例12: EasySwitcher
import android.util.AttributeSet; //导入依赖的package包/类
public EasySwitcher(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
mAllItemArray = new ArrayList<>();
mDefaultSelection = 0;
initBaseView();
}
示例13: initAttrs
import android.util.AttributeSet; //导入依赖的package包/类
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();
}
示例14: TextScalePreference
import android.util.AttributeSet; //导入依赖的package包/类
/**
* 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);
}
示例15: LinedEditText
import android.util.AttributeSet; //导入依赖的package包/类
public LinedEditText(Context context, AttributeSet attrs) {
super(context, attrs);
mRect = new Rect();
mPaint = new Paint();
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setColor(0x800000FF);
}