当前位置: 首页>>代码示例>>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;未经允许,请勿转载。