本文整理汇总了Java中android.content.res.TypedArray.getDimensionPixelOffset方法的典型用法代码示例。如果您正苦于以下问题:Java TypedArray.getDimensionPixelOffset方法的具体用法?Java TypedArray.getDimensionPixelOffset怎么用?Java TypedArray.getDimensionPixelOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.res.TypedArray
的用法示例。
在下文中一共展示了TypedArray.getDimensionPixelOffset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
if (!isInEditMode()) {
}
random = new Random();
if (attrs != null) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.CityView, defStyleAttr, R.style.CityViewTheme);
int buildingsNumber;
try {
buildingsNumber = ta.getInt(R.styleable.CityView_buildings_number, 4);
int defaultPadding = getContext().getResources().getDimensionPixelOffset(R.dimen.build_padding);
buildsPadding = ta.getDimensionPixelOffset(R.styleable.CityView_buildings_padding, defaultPadding);
heightParts = ta.getInt(R.styleable.CityView_buildings_height_parts, HEIGHT_PARTS);
} finally {
ta.recycle();
}
for (int i = 0; i < buildingsNumber; i++) {
addView(new BuildingView(context, attrs, defStyleAttr));
}
}
}
示例2: readStyleParameters
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void readStyleParameters(AttributeSet attrs) {
TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.HTViewPagerWithIndicator);
mTitleOffset = typedArray.getDimensionPixelOffset(R.styleable.HTViewPagerWithIndicator_htTabViewOffset, 0);
//读取padding属性
int paddingLeft = typedArray.getDimensionPixelOffset(R.styleable.HTViewPagerWithIndicator_htTabLayoutPaddingLeft, 0);
int paddingRight = typedArray.getDimensionPixelOffset(R.styleable.HTViewPagerWithIndicator_htTabLayoutPaddingRight, 0);
int paddingTop = typedArray.getDimensionPixelOffset(R.styleable.HTViewPagerWithIndicator_htTabLayoutPaddingTop, 0);
int paddingBottom = typedArray.getDimensionPixelOffset(R.styleable.HTViewPagerWithIndicator_htTabLayoutPaddingBottom, 0);
setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
//读取背景色
Drawable background = typedArray.getDrawable(R.styleable.HTViewPagerWithIndicator_htTabLayoutBackground);
if (background != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
setBackground(background);
} else {
setBackgroundDrawable(background);
}
}
typedArray.recycle();
}
示例3: initTypedArray
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initTypedArray(AttributeSet attributeSet) {
TypedArray typedArray = context.obtainStyledAttributes(attributeSet, R.styleable.CarouselView);
delayTime = typedArray.getInt(R.styleable.CarouselView_carousel_delayTime, DEFAULT_DELAY_TIME);
isAutoSwitch = typedArray.getBoolean(R.styleable.CarouselView_carousel_auto_switch, false);
canLoop = typedArray.getBoolean(R.styleable.CarouselView_carousel_can_loop, true);
isShowIndicator = typedArray.getBoolean(R.styleable.CarouselView_carousel_show_indicator, false);
indicatorWidth = typedArray.getDimensionPixelOffset(R.styleable.CarouselView_carousel_indicator_width
, getResources().getDimensionPixelOffset(R.dimen.carousel_default_indicator_width));
indicatorHeight = typedArray.getDimensionPixelOffset(R.styleable.CarouselView_carousel_indicator_height
, getResources().getDimensionPixelOffset(R.dimen.carousel_default_indicator_height));
indicatorSelectedWidth = typedArray.getDimensionPixelOffset(R.styleable.CarouselView_carousel_indicator_selected_width, 0);
indicatorSelectedHeight = typedArray.getDimensionPixelOffset(R.styleable.CarouselView_carousel_indicator_selected_height, 0);
indicatorUnSelectedWidth = typedArray.getDimensionPixelOffset(R.styleable.CarouselView_carousel_indicator_unselected_width, 0);
indicatorUnSelectedHeight = typedArray.getDimensionPixelOffset(R.styleable.CarouselView_carousel_indicator_unselected_height, 0);
indicatorPadding = typedArray.getDimensionPixelOffset(R.styleable.CarouselView_carousel_indicator_padding
, getResources().getDimensionPixelOffset(R.dimen.carousel_default_indicator_padding));
indicatorMarginBottom = typedArray.getDimensionPixelOffset(R.styleable.CarouselView_carousel_indicator_margin_bottom
, getResources().getDimensionPixelOffset(R.dimen.carousel_default_indicator_margin_bottom));
indicatorSelected = typedArray.getResourceId(R.styleable.CarouselView_carousel_indicator_drawable_selected
, R.drawable.ic_default_indicator_selected);
indicatorUnselected = typedArray.getResourceId(R.styleable.CarouselView_carousel_indicator_drawable_unselected
, R.drawable.ic_default_indicator_unselected);
typedArray.recycle();
haveSpecialIndicator = ((indicatorSelectedWidth > 0 && indicatorSelectedHeight > 0) || (indicatorUnSelectedWidth > 0 && indicatorUnSelectedHeight > 0));
}
示例4: initView
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initView(Context context, AttributeSet attrs, int defStyleAttr) {
mMountPaint.setAntiAlias(true);
mMountPaint.setStyle(Paint.Style.FILL);
mTrunkPaint.setAntiAlias(true);
mBranchPaint.setAntiAlias(true);
mBoarderPaint.setAntiAlias(true);
mBoarderPaint.setStyle(Paint.Style.STROKE);
mBoarderPaint.setStrokeWidth(2);
mBoarderPaint.setStrokeJoin(Paint.Join.ROUND);
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.MountanScenceView);
if (ta.hasValue(R.styleable.MountanScenceView_msvPrimaryColor)) {
setPrimaryColor(ta.getColor(R.styleable.MountanScenceView_msvPrimaryColor, 0xff000000));
}
mViewportHeight = ta.getDimensionPixelOffset(R.styleable.MountanScenceView_msvViewportHeight, 0);
ta.recycle();
updateMountainPath(mMoveFactor, HEIGHT);
updateTreePath(mMoveFactor, true);
}
示例5: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(AttributeSet attrs, int defStyleAttr, int defStyleRes) {
final Context context = getContext();
final Resources resources = getResources();
final float density = resources.getDisplayMetrics().density;
int vSpace = (int) (4 * density);
int hSpace = vSpace;
if (attrs != null) {
// Load attributes
final TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.TweetPicturesLayout, defStyleAttr, defStyleRes);
// Load clip touch corner radius
vSpace = a.getDimensionPixelOffset(R.styleable.TweetPicturesLayout_verticalSpace, vSpace);
hSpace = a.getDimensionPixelOffset(R.styleable.TweetPicturesLayout_horizontalSpace, hSpace);
setColumn(a.getInt(R.styleable.TweetPicturesLayout_column, 3));
setMaxPictureSize(a.getDimensionPixelOffset(R.styleable.TweetPicturesLayout_maxPictureSize, 0));
a.recycle();
}
setVerticalSpacing(vSpace);
setHorizontalSpacing(hSpace);
}
示例6: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs) {
//init the value
borderWidth = 0;
borderColor = 0xddffffff;
pressAlpha = 0x42;
pressColor = 0x42000000;
radius = 16;
shapeType = 0;
// get attribute of EaseImageView
if (attrs != null) {
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.EaseImageView);
borderColor = array.getColor(R.styleable.EaseImageView_ease_border_color, borderColor);
borderWidth = array.getDimensionPixelOffset(R.styleable.EaseImageView_ease_border_width, borderWidth);
pressAlpha = array.getInteger(R.styleable.EaseImageView_ease_press_alpha, pressAlpha);
pressColor = array.getColor(R.styleable.EaseImageView_ease_press_color, pressColor);
radius = array.getDimensionPixelOffset(R.styleable.EaseImageView_ease_radius, radius);
shapeType = array.getInteger(R.styleable.EaseImageView_ease_shape_type, shapeType);
array.recycle();
}
// set paint when pressed
pressPaint = new Paint();
pressPaint.setAntiAlias(true);
pressPaint.setStyle(Paint.Style.FILL);
pressPaint.setColor(pressColor);
pressPaint.setAlpha(0);
pressPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
setClickable(true);
setDrawingCacheEnabled(true);
setWillNotDraw(false);
}
示例7: initFromAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initFromAttributes(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.ScrollLayout);
if (a.hasValue(R.styleable.ScrollLayout_maxOffset)) {
int maxset = a.getDimensionPixelOffset(R.styleable.ScrollLayout_maxOffset, maxOffset);
if (maxset != getScreenHeight()) {
maxOffset = getScreenHeight() - maxset;
}
}
if (a.hasValue(R.styleable.ScrollLayout_minOffset))
minOffset = a.getDimensionPixelOffset(R.styleable.ScrollLayout_minOffset, minOffset);
if (a.hasValue(R.styleable.ScrollLayout_exitOffset)) {
int exitset = a.getDimensionPixelOffset(R.styleable.ScrollLayout_exitOffset, getScreenHeight());
if (exitset != getScreenHeight()) {
exitOffset = getScreenHeight() - exitset;
}
}
if (a.hasValue(R.styleable.ScrollLayout_allowHorizontalScroll))
isAllowHorizontalScroll = a.getBoolean(R.styleable.ScrollLayout_allowHorizontalScroll, true);
if (a.hasValue(R.styleable.ScrollLayout_isSupportExit))
isSupportExit = a.getBoolean(R.styleable.ScrollLayout_isSupportExit, true);
if (a.hasValue(R.styleable.ScrollLayout_mode)) {
int mode = a.getInteger(R.styleable.ScrollLayout_mode, 0);
switch (mode) {
case 0x0:
setToOpen();
break;
case 0x1:
setToClosed();
break;
case 0x2:
setToExit();
break;
default:
setToClosed();
break;
}
}
a.recycle();
}
示例8: ItemInfoLayout
import android.content.res.TypedArray; //导入方法依赖的package包/类
public ItemInfoLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.ItemInfoLayout);
itemText = array.getString(R.styleable.ItemInfoLayout_item_text);
itemTextSize = (int) array.getDimension(R.styleable.ItemInfoLayout_item_textSize, dpToPx(DEFAULT_TEXT_SIZE));
itemTextColor = array.getColor(R.styleable.ItemInfoLayout_item_textColor, DEFAULT_TEXT_COLOR);
itemDarkText = array.getString(R.styleable.ItemInfoLayout_item_dark_text);
itemDarkTextSize = (int) array.getDimension(R.styleable.ItemInfoLayout_item_dark_textSize, dpToPx(DEFAULT_DARK_TEXT_SIZE));
itemDarkTextColor = array.getColor(R.styleable.ItemInfoLayout_item_dark_textColor, DEFAULT_DARK_TEXT_COLOR);
leftDrawPadding = (int) array.getDimension(R.styleable.ItemInfoLayout_item_left_draw_padding, DEFAULT_DRAW_PADDING_SIZE);
rightDrawPadding = (int) array.getDimension(R.styleable.ItemInfoLayout_item_right_draw_padding, DEFAULT_DRAW_PADDING_SIZE);
leftDrawableRes = array.getResourceId(R.styleable.ItemInfoLayout_item_left_res, leftDrawableRes);
rightDrawableRes = array.getResourceId(R.styleable.ItemInfoLayout_item_right_res, rightDrawableRes);
darkDrawableRes = array.getResourceId(R.styleable.ItemInfoLayout_item_dark_res, darkDrawableRes);
itemDarkId = array.getResourceId(R.styleable.ItemInfoLayout_item_dark_id, View.NO_ID);
itemDarkTag = array.getString(R.styleable.ItemInfoLayout_item_dark_tag);
itemTag = array.getString(R.styleable.ItemInfoLayout_item_text_tag);
darkImageSize = array.getDimensionPixelOffset(R.styleable.ItemInfoLayout_item_dark_image_size, darkImageSize);
isRedDotMode = array.getBoolean(R.styleable.ItemInfoLayout_item_is_red_dot_mode, false);
array.recycle();
initLayout();
if (isInEditMode()) {
if (TextUtils.isEmpty(itemText)) {
setItemText("一条Item测试数据");
}
//setRightDrawableRes(R.drawable.base_next);
//setRedDotMode(true);
}
}
示例9: RLinearLayout
import android.content.res.TypedArray; //导入方法依赖的package包/类
public RLinearLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RLinearLayout);
mBackgroundDrawable = typedArray.getDrawable(R.styleable.RLinearLayout_r_background);
maxHeight = typedArray.getDimensionPixelOffset(R.styleable.RLinearLayout_r_max_height, -1);
autoFixNewLine = typedArray.getBoolean(R.styleable.RLinearLayout_r_auto_fix_new_line, autoFixNewLine);
reverseLayout = typedArray.getBoolean(R.styleable.RLinearLayout_r_reverse_layout, reverseLayout);
isInChatLayout = typedArray.getBoolean(R.styleable.RLinearLayout_r_is_in_chat_layout, isInChatLayout);
widthHeightRatio = typedArray.getString(R.styleable.RLinearLayout_r_width_height_ratio);
typedArray.recycle();
resetMaxHeight();
initLayout();
}
示例10: WheelView
import android.content.res.TypedArray; //导入方法依赖的package包/类
public WheelView(Context context, AttributeSet attrs) {
super(context, attrs);
/* textColorOut = getResources().getColor(R.color.pickerview_wheelview_textcolor_out);
textColorCenter =getResources().getColor(R.color.pickerview_wheelview_textcolor_center);
dividerColor = getResources().getColor(R.color.pickerview_wheelview_textcolor_out);*/
textSize = (int) (getResources().getDisplayMetrics().density * 16f);//默认大小
DisplayMetrics dm = getResources().getDisplayMetrics();
float density = dm.density; // 屏幕密度(0.75/1.0/1.5/2.0/3.0)
if (density < 1) {//根据密度不同进行适配
CENTERCONTENTOFFSET = 2.4F;
} else if (1 <= density && density < 2) {
CENTERCONTENTOFFSET = 3.6F;
} else if (1 <= density && density < 2) {
CENTERCONTENTOFFSET = 4.5F;
} else if (2 <= density && density < 3) {
CENTERCONTENTOFFSET = 6.0F;
} else if (density >= 3) {
CENTERCONTENTOFFSET = density * 2.5F;
}
if (attrs != null) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.pickerview, 0, 0);
mGravity = a.getInt(R.styleable.pickerview_pickerview_gravity, Gravity.CENTER);
textColorOut = a.getColor(R.styleable.pickerview_pickerview_textColorOut, textColorOut);
textColorCenter = a.getColor(R.styleable.pickerview_pickerview_textColorCenter, textColorCenter);
dividerColor = a.getColor(R.styleable.pickerview_pickerview_dividerColor, dividerColor);
textSize = a.getDimensionPixelOffset(R.styleable.pickerview_pickerview_textSize, textSize);
lineSpacingMultiplier = a.getFloat(R.styleable.pickerview_pickerview_lineSpacingMultiplier, lineSpacingMultiplier);
a.recycle();//回收内存
}
judgeLineSpae();
initLoopView(context);
}
示例11: TestView
import android.content.res.TypedArray; //导入方法依赖的package包/类
public TestView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TestView, defStyleAttr, 0);
mBorderColor = a.getColor(R.styleable.TestView_tv_border_color, Color.RED);
mBorderWidth = a.getDimensionPixelOffset(R.styleable.TestView_tv_border_width, 2);
mDrawableLeftAndRight = a.getDrawable(R.styleable.TestView_tv_drawable_left_and_right);
setDrawableLeftAndRight(mDrawableLeftAndRight);
a.recycle();
mPaint = new Paint();
mPaint.setStyle(Paint.Style.STROKE);
}
示例12: initStyle
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initStyle(Context context, AttributeSet attrs)
{
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.AutoWrapTextViewStyle);
mPaddingLeft = typedArray.getDimensionPixelSize(R.styleable.AutoWrapTextViewStyle_paddingLeft, 0);
mPaddingRight = typedArray.getDimensionPixelOffset(R.styleable.AutoWrapTextViewStyle_paddingRight, 0);
mPaddingTop = typedArray.getDimensionPixelOffset(R.styleable.AutoWrapTextViewStyle_paddingTop, 0);
mPaddingBottom = typedArray.getDimensionPixelOffset(R.styleable.AutoWrapTextViewStyle_paddingBottom, 0);
mTextColor = typedArray.getColor(R.styleable.AutoWrapTextViewStyle_textColor, Color.BLACK);
mTextSize = typedArray.getDimensionPixelSize(R.styleable.AutoWrapTextViewStyle_textSize, 50);
mLineSpacingExtra = typedArray.getInteger(R.styleable.AutoWrapTextViewStyle_lineSpacingExtra, 7);
typedArray.recycle();
}
示例13: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.UILine);
mOrientation = a.getInt(R.styleable.UILine_ws_line_orientation, ORIENTATION_HORIZONTAL);
mThickness = a.getDimensionPixelSize(R.styleable.UILine_ws_line_thickness, 1);
mColor = a.getColor(R.styleable.UILine_ws_line_color, ResouceUtil.getColor(R.color.line_stoke));
mLineMode = a.getInt(R.styleable.UILine_ws_line_mode, LINE_MODE_REAL);
mDottedSize = a.getDimensionPixelOffset(R.styleable.UILine_ws_line_dotted_size, 20);
mDottedSpacingSize = a.getDimensionPixelOffset(R.styleable.UILine_ws_line_dotted_spacing, 10);
mTag = a.getString(R.styleable.UILine_ws_line_tag);
a.recycle();
}
示例14: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.FakerGridView, defStyleAttr, 0);
int count = typedArray.getIndexCount();
for (int i = 0; i < count; i++) {
int index = typedArray.getIndex(i);
if (index == R.styleable.FakerGridView_numColumns) {
mColumns = typedArray.getInteger(index, COLUMNS_DEFAULT);
} else if (index == R.styleable.FakerGridView_horizontalSpacing) {
mHorizontalSpacing = typedArray.getDimensionPixelOffset(index, 0);
} else if (index == R.styleable.FakerGridView_verticalSpacing) {
mVerticalSpacing = typedArray.getDimensionPixelOffset(index, 0);
}
}
typedArray.recycle();
}
示例15: obtain
import android.content.res.TypedArray; //导入方法依赖的package包/类
static AirAttribute obtain(final View view, final AttributeSet attrs,
final int defStyleAttr, final int defStyleRes,
int[] attrValues, int attrMinIndex, int attrMaxIndex) {
TypedArray a = view.getContext().obtainStyledAttributes(attrs, attrValues, defStyleAttr, defStyleRes);
Resources resources = view.getResources();
int minHeight = a.getDimensionPixelOffset(attrMinIndex,
resources.getDimensionPixelOffset(R.dimen.airPanelMinHeight));
int maxHeight = a.getDimensionPixelOffset(attrMaxIndex,
resources.getDimensionPixelOffset(R.dimen.airPanelMaxHeight));
a.recycle();
AirAttribute attribute = new AirAttribute();
attribute.panelMinHeight = minHeight;
attribute.panelMaxHeight = maxHeight;
return attribute;
}