手记

关于代码中设置颜色和高度(控件)

1.设置颜色用getResources().getColor();

一定要在构造函数Adapter或者在onCreate();

比如:mGreedColor = context.getResources().getColor(R.color.MainGreed);
public ServeRightAdapter(Context context) {
    this.mContext = context;
    this.mInflater = LayoutInflater.from(context);

    mGreedColor = context.getResources().getColor(R.color.MainGreed);
设值:stateTextView.setTextColor(mRedColor);

2.设置高度用getResources().getDimension();

同理需要初始化

比如:mItemHeight = (int) context.getResources().getDimension(R.dimen.usher_table_item_height); 
在values dimen中 <dimen name="usher_queue_item_height">90dp</dimen>
设置:AbsListView.LayoutParams params = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
        mItemHeight);
rowView.setLayoutParams(params);

原文链接:http://www.apkbus.com/blog-455907-59863.html

0人推荐
随时随地看视频
慕课网APP