本文整理汇总了Java中android.content.res.TypedArray类的典型用法代码示例。如果您正苦于以下问题:Java TypedArray类的具体用法?Java TypedArray怎么用?Java TypedArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TypedArray类属于android.content.res包,在下文中一共展示了TypedArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RelativeRadioGroup
import android.content.res.TypedArray; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public RelativeRadioGroup(Context context, AttributeSet attrs) {
super(context, attrs);
// retrieve selected radio button as requested by the user in the
// XML layout file
TypedArray attributes = context.obtainStyledAttributes(
attrs, R.styleable.RelativeRadioGroup, 0, 0);
int value = attributes.getResourceId(R.styleable.RelativeRadioGroup_checkedButton, View.NO_ID);
if (value != View.NO_ID) {
mCheckedId = value;
}
attributes.recycle();
init();
}
示例2: CurrencyPreference
import android.content.res.TypedArray; //导入依赖的package包/类
public CurrencyPreference(Context context, AttributeSet attrs) {
super(context, attrs);
//setDialogLayoutResource(R.layout.currency_picker);
preferences = PreferenceManager.getDefaultSharedPreferences(context);
setCurrenciesList(ExtendedCurrency.getAllCurrencies());
editor = preferences.edit();
setSummary(preferences.getString(getKey(), getValue()));
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.attrs_currency, 0, 0);
try {
defaultCurrencyCode = a.getString(R.styleable.attrs_currency_currencyCode);
} finally {
a.recycle();
}
}
示例3: SlidingTabLayout
import android.content.res.TypedArray; //导入依赖的package包/类
public SlidingTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setFillViewport(true);//设置滚动视图是否可以伸缩其内容以填充视口
setWillNotDraw(false);//重写onDraw方法,需要调用这个方法来清除flag
setClipChildren(false);
setClipToPadding(false);
this.mContext = context;
mTabsContainer = new LinearLayout(context);
addView(mTabsContainer);
obtainAttributes(context, attrs);
//get layout_height
String height = attrs.getAttributeValue("http://schemas.android.com/apk/res/android", "layout_height");
if (height.equals(ViewGroup.LayoutParams.MATCH_PARENT + "")) {
} else if (height.equals(ViewGroup.LayoutParams.WRAP_CONTENT + "")) {
} else {
int[] systemAttrs = {android.R.attr.layout_height};
TypedArray a = context.obtainStyledAttributes(attrs, systemAttrs);
mHeight = a.getDimensionPixelSize(0, ViewGroup.LayoutParams.WRAP_CONTENT);
a.recycle();
}
}
示例4: attachToActivity
import android.content.res.TypedArray; //导入依赖的package包/类
public void attachToActivity(Activity activity) {
mActivity = activity;
TypedArray a = activity.getTheme().obtainStyledAttributes(new int[]{
android.R.attr.windowBackground
});
int background = a.getResourceId(0, 0);
a.recycle();
ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();
ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
decorChild.setBackgroundResource(background);
decor.removeView(decorChild);
addView(decorChild);
setContentView(decorChild);
decor.addView(this);
}
示例5: SlideLayout
import android.content.res.TypedArray; //导入依赖的package包/类
public SlideLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (!isInEditMode()) {
setSystemUiVisibility(SYSTEM_UI_FLAG_HIDE_NAVIGATION | SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlideLayout);
int inAnimation = ta.getResourceId(R.styleable.SlideLayout_nextInAnimation, 0);
int outAnimation = ta.getResourceId(R.styleable.SlideLayout_nextOutAnimation, 0);
int tweetRes = ta.getResourceId(R.styleable.SlideLayout_tweet, 0);
String tweet;
if (tweetRes > 0) {
tweet = context.getResources().getString(tweetRes);
} else {
tweet = ta.getString(R.styleable.SlideLayout_tweet);
}
int notesRes = ta.getResourceId(R.styleable.SlideLayout_notes, 0);
String notes;
if (notesRes > 0) {
notes = context.getResources().getString(notesRes);
} else {
notes = ta.getString(R.styleable.SlideLayout_notes);
}
boolean autoStart = ta.getBoolean(R.styleable.SlideLayout_autoStart, false);
ta.recycle();
phasedLayout = new PhasedLayout(context, inAnimation, outAnimation, tweet, notes, autoStart);
}
}
示例6: ThumbnailView
import android.content.res.TypedArray; //导入依赖的package包/类
public ThumbnailView(final Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
inflate(context, R.layout.thumbnail_view, this);
this.radius = getResources().getDimensionPixelSize(R.dimen.message_bubble_corner_radius);
this.image = (ImageView) findViewById(R.id.thumbnail_image);
this.playOverlay = (ImageView) findViewById(R.id.play_overlay);
super.setOnClickListener(new ThumbnailClickDispatcher());
if (attrs != null) {
TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ThumbnailView, 0, 0);
backgroundColorHint = typedArray.getColor(0, Color.BLACK);
typedArray.recycle();
}
}
示例7: MaxHeightScrollView
import android.content.res.TypedArray; //导入依赖的package包/类
public MaxHeightScrollView(Context c, AttributeSet attrs) {
super(c, attrs);
TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.MaxHeightScrollView);
this.maxHeight = a.getDimensionPixelSize(R.styleable.MaxHeightScrollView_android_maxHeight, Utils.dp(300));
a.recycle();
}
示例8: CameraGLSurfaceView
import android.content.res.TypedArray; //导入依赖的package包/类
public CameraGLSurfaceView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
int cameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
styledAttrs.recycle();
if(android.os.Build.VERSION.SDK_INT >= 21)
mRenderer = new Camera2Renderer(this);
else
mRenderer = new CameraRenderer(this);
setCameraIndex(cameraIndex);
setEGLContextClientVersion(2);
setRenderer(mRenderer);
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
示例9: init
import android.content.res.TypedArray; //导入依赖的package包/类
private void init(Context context, AttributeSet attrs) {
TypedArray typedArray = null;
if (attrs != null)
typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.sub_tab);
mTextSize = typedArray.getDimension(R.styleable.sub_tab_textSize, -1.0F);
tabSelectTextColor = typedArray.getColor(R.styleable.sub_tab_textSelectColor, context.getResources().getColor(R.color.sub_tab_unselected));
tabUnSelectTextColor = typedArray.getColor(R.styleable.sub_tab_textUnSelectColor, context.getResources().getColor(R.color.sub_tab_unselected));
mLeftUnSelectDrawable = typedArray.getDrawable(R.styleable.sub_tab_round_left_unselected);
mRightUnSelectDrawable = typedArray.getDrawable(R.styleable.sub_tab_round_right_unselected);
mSimpleUnSelectDrawable = typedArray.getDrawable(R.styleable.sub_tab_round_none_unselected);
mLeftSelectDrawable = typedArray.getDrawable(R.styleable.sub_tab_round_left_selected);
mRightSelectDrawable = typedArray.getDrawable(R.styleable.sub_tab_round_right_selected);
mSimpleSelectDrawable = typedArray.getDrawable(R.styleable.sub_tab_round_none_selected);
mLeftText = typedArray.getString(R.styleable.sub_tab_round_left_text);
mSimpleText = typedArray.getString(R.styleable.sub_tab_round_none_text);
mRightText = typedArray.getString(R.styleable.sub_tab_round_right_text);
typedArray.recycle();
}
示例10: initTypedArray
import android.content.res.TypedArray; //导入依赖的package包/类
private void initTypedArray(Context context, AttributeSet attrs) {
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.FilterBarLayout);
mFirstFilterTitle = typedArray.getString(R.styleable.FilterBarLayout_firstFilterText);
mSecondFilterTitle = typedArray.getString(R.styleable.FilterBarLayout_secondFilterText);
mThirdFilterTitle = typedArray.getString(R.styleable.FilterBarLayout_thirdFilterText);
mFourthFilterTitle = typedArray.getString(R.styleable.FilterBarLayout_fourthFilterText);
mFifthFilterTitle = typedArray.getString(R.styleable.FilterBarLayout_fifthFilterText);
mFilterBarHeight = (int) typedArray.getDimension(R.styleable.FilterBarLayout_filterBarHeight, DEFAULT_FILTER_BAR_UNIT_HEIGHT);
mFilterTitleSize = typedArray.getDimension(R.styleable.FilterBarLayout_filterTextSize, DEFAULT_FILTER_TITLE_SIZE);
mFilterTitleColor = typedArray.getColor(R.styleable.FilterBarLayout_filterTextColor, DEFAULT_FILTER_TITLE_COLOR);
mFilterTitleSelectedColor = typedArray.getColor(R.styleable.FilterBarLayout_filterTextSelectedColor, DEFAULT_FILTER_TITLE_SELECTED_COLOR);
mFilterCoverColor = typedArray.getColor(R.styleable.FilterBarLayout_filterCoverColor, DEFAULT_FILTER_COVER_COLOR);
mIndicatorDrawable = typedArray.getDrawable(R.styleable.FilterBarLayout_indicatorDrawable);
mIndicatorSelectedDrawable = typedArray.getDrawable(R.styleable.FilterBarLayout_indicatorSelectedDrawable);
mIndicatorGravity = typedArray.getInt(R.styleable.FilterBarLayout_indicatorGravity, DEFAULT_INDICATOR_GRAVITY);
typedArray.recycle();
initializeFromTypedArray();
}
示例11: SlidingUpPanelLayout
import android.content.res.TypedArray; //导入依赖的package包/类
public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SlidingUpPanelLayout, defStyle, 0);
isSlidingEnabled = !a.getBoolean(R.styleable.SlidingUpPanelLayout_spl_disableSliding, false);
mExpandThreshold = a.getFloat(R.styleable.SlidingUpPanelLayout_spl_expandThreshold, 0.0f);
mCollapseThreshold = a.getFloat(R.styleable.SlidingUpPanelLayout_spl_collapseThreshold, 0.7f);
a.recycle();
if (isInEditMode()) {
mDragHelper = null;
return;
}
mDragHelper = ViewDragHelper.create(this, 1.0f, new DragHelperCallback());
mDragHelper.setMinVelocity(DEFAULT_MIN_FLING_VELOCITY * getResources().getDisplayMetrics().density);
}
示例12: init
import android.content.res.TypedArray; //导入依赖的package包/类
void init(AttributeSet attrs) {
resources = context.getResources();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.VectorMasterView);
final int N = a.getIndexCount();
for (int i = 0; i < N; ++i) {
int attr = a.getIndex(i);
if (attr == R.styleable.VectorMasterView_vector_src) {
resID = a.getResourceId(attr, -1);
} else if (attr == R.styleable.VectorMasterView_use_legacy_parser) {
useLegacyParser = a.getBoolean(attr, false);
}
}
a.recycle();
buildVectorModel();
}
示例13: CircleImageView
import android.content.res.TypedArray; //导入依赖的package包/类
public CircleImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
super.setScaleType(SCALE_TYPE);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView, defStyle, 0);
mBorderWidth = a.getDimensionPixelSize(R.styleable.CircleImageView_border_width, DEFAULT_BORDER_WIDTH);
mBorderColor = a.getColor(R.styleable.CircleImageView_border_color, Color.WHITE);
a.recycle();
mReady = true;
if (mSetupPending) {
setup();
mSetupPending = false;
}
}
示例14: init
import android.content.res.TypedArray; //导入依赖的package包/类
private void init(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.XGallery, defStyleAttr, 0);
int itemWidth = a.getDimensionPixelOffset(R.styleable.XGallery_xGallery_itemWidth, LayoutParams.MATCH_PARENT);
int itemHeight = a.getDimensionPixelOffset(R.styleable.XGallery_xGallery_itemHeight, LayoutParams.MATCH_PARENT);
a.recycle();
mViewPager = new ViewPager(context);
mViewPager.setClipChildren(false);
mViewPager.setOverScrollMode(OVER_SCROLL_NEVER);
mViewPager.setHorizontalScrollBarEnabled(false);
mViewPager.setOffscreenPageLimit(5);
setPageTransformer(new BottomScalePageTransformer());
LayoutParams params = new LayoutParams(itemWidth, itemHeight);
params.gravity = Gravity.CENTER;
addView(mViewPager, params);
setClipChildren(false);
setOnTouchListener(this);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
mTapTimeout = ViewConfiguration.getTapTimeout();
mViewPagerWidth = itemWidth;
}
示例15: CircleLineProgress
import android.content.res.TypedArray; //导入依赖的package包/类
public CircleLineProgress(Context context, AttributeSet attrs) {
super(context, attrs);
paint.setStyle(Paint.Style.STROKE);
TypedArray array=context.getTheme().obtainStyledAttributes(attrs,R.styleable.CircleLineProgress,0,0);
try{
in_rad=array.getDimension(R.styleable.CircleLineProgress_circle_radius,50);
colorArc=array.getColor(R.styleable.CircleLineProgress_circle_color, Color.parseColor("#5C6BC0"));
out_rad=array.getDimension(R.styleable.CircleLineProgress_line_radius,50);
colorArc2=array.getColor(R.styleable.CircleLineProgress_line_color, Color.parseColor("#1A237E"));
}
catch (Exception e){
e.printStackTrace();
}
finally {
array.recycle();
}
post(animator);
}