當前位置: 首頁>>代碼示例>>Java>>正文


Java AttributeSet.getAttributeValue方法代碼示例

本文整理匯總了Java中android.util.AttributeSet.getAttributeValue方法的典型用法代碼示例。如果您正苦於以下問題:Java AttributeSet.getAttributeValue方法的具體用法?Java AttributeSet.getAttributeValue怎麽用?Java AttributeSet.getAttributeValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.util.AttributeSet的用法示例。


在下文中一共展示了AttributeSet.getAttributeValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: SlidingTabLayout

import android.util.AttributeSet; //導入方法依賴的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");

    //create ViewPager
    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();
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:SlidingTabLayout.java

示例2: SlidingTabLayout

import android.util.AttributeSet; //導入方法依賴的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();
    }
}
 
開發者ID:sunyabin,項目名稱:FlycoTablayout,代碼行數:26,代碼來源:SlidingTabLayout.java

示例3: ColorPreference

import android.util.AttributeSet; //導入方法依賴的package包/類
public ColorPreference(Context context, AttributeSet attrs) {
	super(context, attrs);
	
	attribute = attrs.getAttributeValue(1);
	
	// set the layout so we can see the preview color
	setWidgetLayoutResource(R.layout.prefcolor);

	// figure out what the current color is
	SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
	
	if (attribute.equals("fontcolor"))
		defcolor = 0xFFCCCCCC;
	else
		defcolor = 0xFF000000;
	
	color = sharedPref.getInt(attribute, defcolor);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:19,代碼來源:ColorPreference.java

示例4: setAttributes

import android.util.AttributeSet; //導入方法依賴的package包/類
@Override
protected void setAttributes(AttributeSet attrs) {
	// TODO 自動生成的方法存根
	super.setAttributes(attrs);
	float size = 4;// default ring width
	String width = attrs.getAttributeValue(MATERIALDESIGNXML, "ringWidth");
	if (width != null) {
		size = Utils.dipOrDpToFloat(width);
	}
	ringWidth = size;
}
 
開發者ID:mityung,項目名稱:XERUNG,代碼行數:12,代碼來源:ProgressBarCircularIndeterminate.java

示例5: CommonTabLayout

import android.util.AttributeSet; //導入方法依賴的package包/類
public CommonTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    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");

    //create ViewPager
    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();
    }

    mValueAnimator = ValueAnimator.ofObject(new PointEvaluator(), mLastP, mCurrentP);
    mValueAnimator.addUpdateListener(this);
}
 
開發者ID:LonelyMushroom,項目名稱:aarLibrary,代碼行數:29,代碼來源:CommonTabLayout.java

示例6: SegmentTabLayout

import android.util.AttributeSet; //導入方法依賴的package包/類
public SegmentTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    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");

    //create ViewPager
    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();
    }

    mValueAnimator = ValueAnimator.ofObject(new PointEvaluator(), mLastP, mCurrentP);
    mValueAnimator.addUpdateListener(this);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:29,代碼來源:SegmentTabLayout.java

示例7: setAttributes

import android.util.AttributeSet; //導入方法依賴的package包/類
@Override
protected void setAttributes(AttributeSet attrs) {
	super.setAttributes(attrs);
	if (!isInEditMode()) {
		getBackground().setAlpha(0);
	}
	iSchecked = attrs.getAttributeBooleanValue(MATERIALDESIGNXML, "checked", false);
	eventCheck = iSchecked;
	//添加監聽器,如果點擊了這個控件(不包括ball的區域),這個控件就開始判斷是否是開啟狀態。
	setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View arg0) {
			setChecked(iSchecked ? false : true);
		}
	});
	
	float size = 20;
	String thumbSize = attrs.getAttributeValue(MATERIALDESIGNXML, "thumbSize");
	if (thumbSize != null) {
		size = Utils.dipOrDpToFloat(thumbSize);
	}
	ball = new Ball(getContext());
	setThumbParams(size);
	addView(ball);
	// 給圓球添加監聽器,點擊圓球後就開始判斷是否進入開啟狀態
	ball.setOnClickListener(new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO 自動生成的方法存根
			setChecked(iSchecked ? false : true);
		}
	});
}
 
開發者ID:mityung,項目名稱:XERUNG,代碼行數:35,代碼來源:Switch.java

示例8: SettingItemSwitch

import android.util.AttributeSet; //導入方法依賴的package包/類
public SettingItemSwitch(Context context, AttributeSet attrs) {
    super(context, attrs);
    initView();
    String title = attrs.getAttributeValue(NAMESPACE, "title");
    mDescOn = attrs.getAttributeValue(NAMESPACE, "desc_on");
    mDescOff = attrs.getAttributeValue(NAMESPACE, "desc_off");
    setTitle(title);
}
 
開發者ID:lueans,項目名稱:LueansRead,代碼行數:9,代碼來源:SettingItemSwitch.java

示例9: setAttributes

import android.util.AttributeSet; //導入方法依賴的package包/類
@Override
protected void setAttributes(AttributeSet attrs) {
	// Set text button
	String text = null;
	int textResource = attrs.getAttributeResourceValue(ANDROIDXML,"text",-1);
	if(textResource != -1){
		text = getResources().getString(textResource);
	}else{
		text = attrs.getAttributeValue(ANDROIDXML,"text");
	}
	if(text != null){
		textButton = new TextView(getContext());
		textButton.setText(text.toUpperCase());
		textButton.setTextColor(backgroundColor);
		textButton.setTypeface(null, Typeface.BOLD);
		LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
		textButton.setLayoutParams(params);
		addView(textButton);
	}
	int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,"background",-1);
	if(bacgroundColor != -1){
		setBackgroundColor(getResources().getColor(bacgroundColor));
	}else{
		// Color by hexadecimal
		// Color by hexadecimal
		background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1);
		if (background != -1)
			setBackgroundColor(background);
	}
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:32,代碼來源:ButtonFlat.java

示例10: createViewFromTag

import android.util.AttributeSet; //導入方法依賴的package包/類
public View createViewFromTag(Context context, String name, AttributeSet attrs) {
    if (name.equals("view")) {
        name = attrs.getAttributeValue(null, "class");
    }

    try {
        mConstructorArgs[0] = context;
        mConstructorArgs[1] = attrs;

        if (-1 == name.indexOf('.')) {
            for (int i = 0; i < sClassPrefixList.length; i++) {
                final View view = createView(context, name, sClassPrefixList[i]);
                if (view != null) {
                    return view;
                }
            }
            return null;
        } else {
            return createView(context, name, null);
        }
    } catch (Exception e) {
        // We do not want to catch these, lets return null and let the actual LayoutInflater
        // try
        return null;
    } finally {
        // Don't retain references on context.
        mConstructorArgs[0] = null;
        mConstructorArgs[1] = null;
    }
}
 
開發者ID:ximsfei,項目名稱:Android-skin-support,代碼行數:31,代碼來源:SkinCompatViewInflater.java

示例11: GestureImageView

import android.util.AttributeSet; //導入方法依賴的package包/類
public GestureImageView(Context context, AttributeSet attrs) {
	super(context, attrs);
	
	String scaleType = attrs.getAttributeValue(GLOBAL_NS, "scaleType");
	
	if(scaleType == null || scaleType.trim().length() == 0) {
		setScaleType(ScaleType.CENTER_INSIDE);
	}
	
	String strStartX = attrs.getAttributeValue(LOCAL_NS, "start-x");
	String strStartY = attrs.getAttributeValue(LOCAL_NS, "start-y");
	
	if(strStartX != null && strStartX.trim().length() > 0) {
		startX = Float.parseFloat(strStartX);
	}
	
	if(strStartY != null && strStartY.trim().length() > 0) {
		startY = Float.parseFloat(strStartY);
	}
	
	setStartingScale(attrs.getAttributeFloatValue(LOCAL_NS, "start-scale", startingScale));
	setMinScale(attrs.getAttributeFloatValue(LOCAL_NS, "min-scale", minScale));
	setMaxScale(attrs.getAttributeFloatValue(LOCAL_NS, "max-scale", maxScale));
	setStrict(attrs.getAttributeBooleanValue(LOCAL_NS, "strict", strict));
	setRecycle(attrs.getAttributeBooleanValue(LOCAL_NS, "recycle", recycle));
	
	initImage();
}
 
開發者ID:CactusSoft,項目名稱:zabbkit-android,代碼行數:29,代碼來源:GestureImageView.java

示例12: createViewFromTag

import android.util.AttributeSet; //導入方法依賴的package包/類
private View createViewFromTag(Context context, String name, AttributeSet attrs) {
    if (name.equals("view")) {
        name = attrs.getAttributeValue(null, "class");
    }

    try {
        mConstructorArgs[0] = context;
        mConstructorArgs[1] = attrs;

        if (-1 == name.indexOf('.')) {
            for (int i = 0; i < sClassPrefixList.length; i++) {
                final View view = createView(context, name, sClassPrefixList[i]);
                if (view != null) {
                    return view;
                }
            }
            return null;
        } else {
            return createView(context, name, null);
        }
    } catch (Exception e) {
        // We do not want to catch these, lets return null and let the actual LayoutInflater
        // try
        return null;
    } finally {
        // Don't retain references on context.
        mConstructorArgs[0] = null;
        mConstructorArgs[1] = null;
    }
}
 
開發者ID:chengkun123,項目名稱:ReadMark,代碼行數:31,代碼來源:SkinAppCompatViewInflater.java

示例13: CommonTabLayout

import android.util.AttributeSet; //導入方法依賴的package包/類
public CommonTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    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");

    //create ViewPager
    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();
    }

    mValueAnimator = ValueAnimator.ofObject(new PointEvaluator(), mLastP, mCurrentP);
    mValueAnimator.addUpdateListener(this);
}
 
開發者ID:ynztlxdeai,項目名稱:MVPtemplate,代碼行數:29,代碼來源:CommonTabLayout.java

示例14: SliderPreference

import android.util.AttributeSet; //導入方法依賴的package包/類
public SliderPreference(Context ctxt, AttributeSet attrs) {
    super(ctxt, attrs);
    setLayoutResource(R.layout.slider_preference_layout);
    title = attrs.getAttributeValue("http://schemas.android.com/apk/res/android", "title");

    for (int i=0; i<attrs.getAttributeCount(); i++) {
        Log.d("attrs", i + " " + attrs.getAttributeName(i) + " " + attrs.getAttributeValue(i));
    }

}
 
開發者ID:quaap,項目名稱:SeafoodBerserker,代碼行數:11,代碼來源:SliderPreference.java

示例15: setAttributes

import android.util.AttributeSet; //導入方法依賴的package包/類
@Override
protected void setAttributes(AttributeSet attrs) {
	super.setAttributes(attrs);
	if (!isInEditMode()) {
		getBackground().setAlpha(0);
	}
	showNumberIndicator = attrs.getAttributeBooleanValue(MATERIALDESIGNXML,"showNumberIndicator", false);
	min = attrs.getAttributeIntValue(MATERIALDESIGNXML, "min", 0);
	max = attrs.getAttributeIntValue(MATERIALDESIGNXML, "max", 100);// max > min
	value = attrs.getAttributeIntValue(MATERIALDESIGNXML, "value", min);

	float size = 20;
	String thumbSize = attrs.getAttributeValue(MATERIALDESIGNXML, "thumbSize");
	if (thumbSize != null) {
		size = Utils.dipOrDpToFloat(thumbSize);
	}

	ball = new Ball(getContext());
	setBallParams(size);
	addView(ball);

	// Set if slider content number indicator
	if (showNumberIndicator) {
		if (!isInEditMode()) {
			numberIndicator = new NumberIndicator(getContext());
		}
	}
}
 
開發者ID:mityung,項目名稱:XERUNG,代碼行數:29,代碼來源:Slider.java


注:本文中的android.util.AttributeSet.getAttributeValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。