本文整理匯總了Java中android.content.res.TypedArray.getDrawable方法的典型用法代碼示例。如果您正苦於以下問題:Java TypedArray.getDrawable方法的具體用法?Java TypedArray.getDrawable怎麽用?Java TypedArray.getDrawable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.content.res.TypedArray
的用法示例。
在下文中一共展示了TypedArray.getDrawable方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import android.content.res.TypedArray; //導入方法依賴的package包/類
private void init(Context context, AttributeSet attrs) {
this.context = context;
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.EaseContactList);
primaryColor = ta.getColor(R.styleable.EaseContactList_ctsListPrimaryTextColor, 0);
primarySize = ta.getDimensionPixelSize(R.styleable.EaseContactList_ctsListPrimaryTextSize, 0);
showSiderBar = ta.getBoolean(R.styleable.EaseContactList_ctsListShowSiderBar, true);
initialLetterBg = ta.getDrawable(R.styleable.EaseContactList_ctsListInitialLetterBg);
initialLetterColor = ta.getColor(R.styleable.EaseContactList_ctsListInitialLetterColor, 0);
ta.recycle();
LayoutInflater.from(context).inflate(R.layout.ease_widget_contact_list, this);
listView = (ListView) findViewById(R.id.list);
sidebar = (EaseSidebar) findViewById(R.id.sidebar);
if (!showSiderBar)
sidebar.setVisibility(View.GONE);
}
示例2: retrieveXmlConfiguration
import android.content.res.TypedArray; //導入方法依賴的package包/類
/**
* Parse the XML configuration for this widget
*
* @param context Context used for extracting attributes
* @param attrs The Attribute Set containing the ColumnView attributes
*/
private void retrieveXmlConfiguration(Context context, AttributeSet attrs) {
if (attrs != null) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.HorizontalListView);
// Get the provided drawable from the XML
final Drawable d = a.getDrawable(R.styleable.HorizontalListView_android_divider);
if (d != null) {
// If a drawable is provided to use as the divider then use its intrinsic width for the divider width
setDivider(d);
}
// If a width is explicitly specified then use that width
final int dividerWidth = a.getDimensionPixelSize(R.styleable.HorizontalListView_dividerWidth, 0);
if (dividerWidth != 0) {
setDividerWidth(dividerWidth);
}
a.recycle();
}
}
示例3: EmoticonsIndicatorView
import android.content.res.TypedArray; //導入方法依賴的package包/類
public EmoticonsIndicatorView(Context context, AttributeSet attrs) {
super(context, attrs);
this.mContext = context;
this.setOrientation(HORIZONTAL);
TypedArray a = context.getTheme().obtainStyledAttributes(attrs,
R.styleable.EmoticonsIndicatorView, 0, 0);
try {
mDrawableSelect = a.getDrawable(R.styleable.EmoticonsIndicatorView_bmpSelect);
mDrawableNomal = a.getDrawable(R.styleable.EmoticonsIndicatorView_bmpNomal);
} finally {
a.recycle();
}
if(mDrawableNomal == null) {
mDrawableNomal = getResources().getDrawable(R.drawable.indicator_point_nomal);
}
if(mDrawableSelect == null) {
mDrawableSelect = getResources().getDrawable(R.drawable.indicator_point_select);
}
mLeftLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
mLeftLayoutParams.leftMargin = EmoticonsKeyboardUtils.dip2px(context, MARGIN_LEFT);
}
示例4: BaseContainerView
import android.content.res.TypedArray; //導入方法依賴的package包/類
public BaseContainerView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
if (this instanceof AllAppsContainerView) {
mBaseDrawable = new ColorDrawable();
} else {
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.BaseContainerView, defStyleAttr, 0);
mBaseDrawable = a.getDrawable(R.styleable.BaseContainerView_revealBackground);
a.recycle();
}
}
示例5: getAttrDrawable
import android.content.res.TypedArray; //導入方法依賴的package包/類
static Drawable getAttrDrawable(Context context, AttributeSet attrs, int attr) {
final TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{attr});
final int resId = a.getResourceId(0, 0);
Drawable drawable = null;
if (resId != 0) {
drawable = createDrawable(context, resId);
if (drawable == null) {
drawable = a.getDrawable(0);
}
}
a.recycle();
return drawable;
}
示例6: findElementIcon
import android.content.res.TypedArray; //導入方法依賴的package包/類
public Drawable findElementIcon(TGBrowserElement element) throws TGBrowserException {
Integer style = (element.isFolder() ? R.style.BrowserElementIconFolder : R.style.BrowserElementIconFile);
TypedArray typedArray = this.context.obtainStyledAttributes(style, new int[] {android.R.attr.src});
if( typedArray != null ) {
return typedArray.getDrawable(0);
}
return null;
}
示例7: resolveOptionalAttributes
import android.content.res.TypedArray; //導入方法依賴的package包/類
private void resolveOptionalAttributes(TypedArray typedArray) {
fabDrawable = typedArray.getDrawable(R.styleable.FabSpeedDial_fabDrawable);
if (fabDrawable == null) {
fabDrawable = ContextCompat.getDrawable(getContext(), R.drawable.fab_add_clear_selector);
}
fabDrawableTint = typedArray.getColorStateList(R.styleable.FabSpeedDial_fabDrawableTint);
if (fabDrawableTint == null) {
fabDrawableTint = getColorStateList(getContext(), R.color.fab_drawable_tint);
}
if (typedArray.hasValue(R.styleable.FabSpeedDial_fabBackgroundTint)) {
fabBackgroundTint = typedArray.getColorStateList(R.styleable.FabSpeedDial_fabBackgroundTint);
}
miniFabBackgroundTint = typedArray.getColorStateList(R.styleable.FabSpeedDial_miniFabBackgroundTint);
if (miniFabBackgroundTint == null) {
miniFabBackgroundTint = getColorStateList(getContext(), R.color.fab_background_tint);
}
miniFabDrawableTint = typedArray.getColorStateList(R.styleable.FabSpeedDial_miniFabDrawableTint);
if (miniFabDrawableTint == null) {
miniFabDrawableTint = getColorStateList(getContext(), R.color.mini_fab_drawable_tint);
}
miniFabTitleBackgroundTint = typedArray.getColorStateList(R.styleable.FabSpeedDial_miniFabTitleBackgroundTint);
if (miniFabTitleBackgroundTint == null) {
miniFabTitleBackgroundTint = getColorStateList(getContext(), R.color.mini_fab_title_background_tint);
}
miniFabTitlesEnabled = typedArray.getBoolean(R.styleable.FabSpeedDial_miniFabTitlesEnabled, true);
miniFabTitleTextColor = typedArray.getColor(R.styleable.FabSpeedDial_miniFabTitleTextColor,
ContextCompat.getColor(getContext(), R.color.title_text_color));
touchGuardDrawable = typedArray.getDrawable(R.styleable.FabSpeedDial_touchGuardDrawable);
useTouchGuard = typedArray.getBoolean(R.styleable.FabSpeedDial_touchGuard, true);
}
示例8: setAttributes
import android.content.res.TypedArray; //導入方法依賴的package包/類
private void setAttributes(AttributeSet attrs) {
mHintTextView = new TextView(mContext);
final TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.LabeledEditText);
final int padding = a.getDimensionPixelSize(R.styleable.LabeledEditText_etPadding, 0);
final int defaultPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
DEFAULT_PADDING_LEFT, getResources().getDisplayMetrics());
final int paddingLeft = a.getDimensionPixelSize(R.styleable.LabeledEditText_etPaddingLeft, defaultPadding);
final int paddingTop = a.getDimensionPixelSize(R.styleable.LabeledEditText_etPaddingTop, 0);
final int paddingRight = a.getDimensionPixelSize(R.styleable.LabeledEditText_etPaddingRight, 0);
final int paddingBottom = a.getDimensionPixelSize(R.styleable.LabeledEditText_etPaddingBottom, 0);
Drawable background = a.getDrawable(R.styleable.LabeledEditText_etBackground);
if (padding != 0) {
mHintTextView.setPadding(padding, padding, padding, padding);
} else {
mHintTextView.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
}
if (background != null) {
setHintBackground(background);
}
mHintTextView.setTextAppearance(mContext, a.getResourceId(R.styleable.LabeledEditText_etTextAppearance,
android.R.style.TextAppearance_Small));
//Start hidden
mHintTextView.setVisibility(INVISIBLE);
//AnimatorProxy.wrap(mHintTextView).setAlpha(0);
addView(mHintTextView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
a.recycle();
}
示例9: LinePageIndicator
import android.content.res.TypedArray; //導入方法依賴的package包/類
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.mPaintUnselected = new Paint(1);
this.mPaintSelected = new Paint(1);
this.mLastMotionX = -1.0f;
this.mActivePointerId = -1;
if (!isInEditMode()) {
Resources res = getResources();
int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color);
int defaultUnselectedColor = res.getColor(R.color.default_line_indicator_unselected_color);
float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width);
float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width);
float defaultStrokeWidth = res.getDimension(R.dimen.default_line_indicator_stroke_width);
boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LinePageIndicator, defStyle, 0);
this.mCentered = a.getBoolean(1, defaultCentered);
this.mLineWidth = a.getDimension(5, defaultLineWidth);
this.mGapWidth = a.getDimension(6, defaultGapWidth);
setStrokeWidth(a.getDimension(3, defaultStrokeWidth));
this.mPaintUnselected.setColor(a.getColor(4, defaultUnselectedColor));
this.mPaintSelected.setColor(a.getColor(2, defaultSelectedColor));
Drawable background = a.getDrawable(0);
if (background != null) {
setBackgroundDrawable(background);
}
a.recycle();
this.mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(ViewConfiguration.get(context));
}
}
示例10: CirclePageIndicator
import android.content.res.TypedArray; //導入方法依賴的package包/類
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);
}
示例11: initCustomAttr
import android.content.res.TypedArray; //導入方法依賴的package包/類
private void initCustomAttr(int attr, TypedArray typedArray) {
if (attr == R.styleable.QRCodeView_qrcv_topOffset) {
mTopOffset = typedArray.getDimensionPixelSize(attr, 0);
} else if (attr == R.styleable.QRCodeView_qrcv_cornerSize) {
mCornerSize = typedArray.getDimensionPixelSize(attr, mCornerSize);
} else if (attr == R.styleable.QRCodeView_qrcv_cornerLength) {
mCornerLength = typedArray.getDimensionPixelSize(attr, mCornerLength);
} else if (attr == R.styleable.QRCodeView_qrcv_scanLineSize) {
mScanLineSize = typedArray.getDimensionPixelSize(attr, mScanLineSize);
} else if (attr == R.styleable.QRCodeView_qrcv_rectWidth) {
mRectWidth = typedArray.getDimensionPixelSize(attr, mRectWidth);
} else if (attr == R.styleable.QRCodeView_qrcv_maskColor) {
mMaskColor = typedArray.getColor(attr, mMaskColor);
} else if (attr == R.styleable.QRCodeView_qrcv_cornerColor) {
mCornerColor = typedArray.getColor(attr, Color.WHITE);
} else if (attr == R.styleable.QRCodeView_qrcv_scanLineColor) {
mScanLineColor = typedArray.getColor(attr, Color.WHITE);
} else if (attr == R.styleable.QRCodeView_qrcv_scanLineMargin) {
mScanLineMargin = typedArray.getDimensionPixelSize(attr, 0);
} else if (attr == R.styleable.QRCodeView_qrcv_customScanLineDrawable) {
mCustomScanLineDrawable = typedArray.getDrawable(attr);
} else if (attr == R.styleable.QRCodeView_qrcv_borderSize) {
mBorderSize = typedArray.getDimensionPixelSize(attr, mBorderSize);
} else if (attr == R.styleable.QRCodeView_qrcv_borderColor) {
mBorderColor = typedArray.getColor(attr, Color.WHITE);
} else if (attr == R.styleable.QRCodeView_qrcv_animTime) {
mAnimTime = typedArray.getInteger(attr, 1000);
} else if (attr == R.styleable.QRCodeView_qrcv_isCenterVertical) {
mIsCenterVertical = typedArray.getBoolean(attr, false);
} else if (attr == R.styleable.QRCodeView_qrcv_customGridScanLineDrawable) {
mCustomGridScanLineDrawable = typedArray.getDrawable(attr);
} else if (attr == R.styleable.QRCodeView_qrcv_toolbarHeight) {
mToolbarHeight = typedArray.getDimensionPixelSize(attr, 0);
}
}
示例12: ContentAdapter
import android.content.res.TypedArray; //導入方法依賴的package包/類
public ContentAdapter(Context context) {
Resources resources = context.getResources();
mPlaces = resources.getStringArray(R.array.places);
mPlaceDesc = resources.getStringArray(R.array.place_desc);
TypedArray a = resources.obtainTypedArray(R.array.places_picture);
mPlacePictures = new Drawable[a.length()];
for (int i = 0; i < mPlacePictures.length; i++) {
mPlacePictures[i] = a.getDrawable(i);
}
a.recycle();
}
示例13: DividerItemDecoration
import android.content.res.TypedArray; //導入方法依賴的package包/類
public DividerItemDecoration(Context context, int orientation) {
final TypedArray a = context.obtainStyledAttributes(ATTRS);
mDivider = a.getDrawable(0);
a.recycle();
setOrientation(orientation);
}
示例14: RecyclerViewDivider
import android.content.res.TypedArray; //導入方法依賴的package包/類
public RecyclerViewDivider(Context context) {
TypedArray a = context.obtainStyledAttributes(ATTRS);
mDivider = a.getDrawable(0);
a.recycle();
}
示例15: DividerItemDecoration
import android.content.res.TypedArray; //導入方法依賴的package包/類
public DividerItemDecoration(Context context) {
final TypedArray a = context.obtainStyledAttributes(ATTRS);
mDrawable = a.getDrawable(0);
a.recycle();
}