当前位置: 首页>>代码示例>>Java>>正文


Java TypedArray.getDrawable方法代码示例

本文整理汇总了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);
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:18,代码来源:ContactList.java

示例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();
    }
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:27,代码来源:HorizontalListView.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:EmoticonsIndicatorView.java

示例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();
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:13,代码来源:BaseContainerView.java

示例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;
}
 
开发者ID:Pingsh,项目名称:Mix,代码行数:14,代码来源:DrawableUtils.java

示例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;
}
 
开发者ID:axlecho,项目名称:tuxguitar,代码行数:9,代码来源:TGBrowserListAdapter.java

示例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);
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:41,代码来源:FabSpeedDial.java

示例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();
}
 
开发者ID:yangchong211,项目名称:YCCustomText,代码行数:31,代码来源:LabeledEditText.java

示例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));
    }
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:30,代码来源:LinePageIndicator.java

示例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);
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:41,代码来源:CirclePageIndicator.java

示例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);
    }
}
 
开发者ID:CardInfoLink,项目名称:QRScanner,代码行数:36,代码来源:ScanBoxView.java

示例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();
}
 
开发者ID:TORU0239,项目名称:android-design-library-master,代码行数:12,代码来源:CardContentFragment.java

示例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);
}
 
开发者ID:ahmadnurhidayat,项目名称:TravelJournal,代码行数:7,代码来源:DividerItemDecoration.java

示例14: RecyclerViewDivider

import android.content.res.TypedArray; //导入方法依赖的package包/类
public RecyclerViewDivider(Context context) {
    TypedArray a = context.obtainStyledAttributes(ATTRS);
    mDivider = a.getDrawable(0);
    a.recycle();

}
 
开发者ID:emqtt,项目名称:EMQ-Android-Toolkit,代码行数:7,代码来源:RecyclerViewDivider.java

示例15: DividerItemDecoration

import android.content.res.TypedArray; //导入方法依赖的package包/类
public DividerItemDecoration(Context context) {
    final TypedArray a = context.obtainStyledAttributes(ATTRS);
    mDrawable = a.getDrawable(0);
    a.recycle();
}
 
开发者ID:newbiechen1024,项目名称:NovelReader,代码行数:6,代码来源:DividerItemDecoration.java


注:本文中的android.content.res.TypedArray.getDrawable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。