java utils类_Java Utils类代码示例

import it.neokree.materialnavigationdrawer.util.Utils; //导入依赖的package包/类

public MaterialSubheader(Context ctx) {

float density = ctx.getResources().getDisplayMetrics().density;

// create layout

LinearLayout layout = new LinearLayout(ctx);

layout.setOrientation(LinearLayout.VERTICAL);

// inflate the line

View view = new View(ctx);

view.setBackgroundColor(Color.parseColor("#8f8f8f"));

LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,1);

params.setMargins(0,(int) (8 * density), 0 , (int) (8 * density));

layout.addView(view,params);

// inflate the text

text = new TextView(ctx);

Utils.setAlpha(text,0.54f);

text.setTextSize(TypedValue.COMPLEX_UNIT_SP,14);

text.setGravity(Gravity.START);

LinearLayout.LayoutParams paramsText = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

paramsText.setMargins((int) (16 * density),0, (int) (16 * density) , (int) (4 * density));

layout.addView(text,paramsText);

this.view = layout;

// get attributes from current theme

Resources.Theme theme = ctx.getTheme();

TypedValue typedValue = new TypedValue();

theme.resolveAttribute(R.attr.sectionStyle,typedValue,true);

TypedArray values = theme.obtainStyledAttributes(typedValue.resourceId,R.styleable.MaterialSection);

try {

titleColor = values.getColor(R.styleable.MaterialSubheader_subheaderTitleColor,0x000);

}

finally {

values.recycle();

}

// set attributes to the view

text.setTextColor(Color.BLACK);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值