本文整理匯總了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();
}
}
示例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();
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
});
}
示例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);
}
示例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);
}
}
示例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;
}
}
示例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();
}
示例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;
}
}
示例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);
}
示例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));
}
}
示例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());
}
}
}