当前位置: 首页>>代码示例>>Java>>正文


Java ResHelper.dipToPx方法代码示例

本文整理汇总了Java中com.mob.tools.utils.ResHelper.dipToPx方法的典型用法代码示例。如果您正苦于以下问题:Java ResHelper.dipToPx方法的具体用法?Java ResHelper.dipToPx怎么用?Java ResHelper.dipToPx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mob.tools.utils.ResHelper的用法示例。


在下文中一共展示了ResHelper.dipToPx方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import com.mob.tools.utils.ResHelper; //导入方法依赖的package包/类
private void init(Context context) {
	setCanceledOnTouchOutside(true);//触摸屏幕取消窗体
	setCancelable(false);//按返回键取消窗体
	Window window = getWindow();
	window.setWindowAnimations(ResHelper.getStyleRes(context, "BBS_AnimFadeInOut"));

	//setup view
	LinearLayout llItem = new LinearLayout(context);
	int padding = ResHelper.dipToPx(context, 30);
	llItem.setPadding(padding, padding, padding, padding);
	llItem.setBackgroundResource(ResHelper.getBitmapRes(context, "bbs_bg_warning_dialog"));
	llItem.setOrientation(LinearLayout.VERTICAL);
	IOSLoadingView loadingView = new IOSLoadingView(context);
	LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
	llp.gravity = Gravity.CENTER_HORIZONTAL;
	llItem.addView(loadingView, llp);

	WindowManager.LayoutParams params = new WindowManager.LayoutParams(ResHelper.dipToPx(getContext(), 400), ViewGroup.LayoutParams.WRAP_CONTENT);
	params.gravity = Gravity.CENTER;
	window.setContentView(llItem, params);
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:22,代码来源:ModelLoadingDialog.java

示例2: init

import com.mob.tools.utils.ResHelper; //导入方法依赖的package包/类
private void init(Context context) {
	data = new ArrayList<String>();
	itemHeight = ResHelper.dipToPx(getContext(), 37);
	sepHeight = ResHelper.dipToPx(getContext(), 1);

	normalPaint = new Paint();
	normalPaint.setColor(0xffcccccc);
	normalPaint.setTextSize(ResHelper.dipToPx(getContext(), 14));
	normalPaint.setAntiAlias(true);
	normalPaint.setTextAlign(Paint.Align.CENTER);

	selectedPaint = new Paint();
	selectedPaint.setColor(0xffe3564b);
	selectedPaint.setTextSize(ResHelper.dipToPx(getContext(), 16));
	selectedPaint.setAntiAlias(true);
	selectedPaint.setTextAlign(Paint.Align.CENTER);

	ViewConfiguration configuration = ViewConfiguration.get(context);
	maximumVelocity = configuration.getScaledMaximumFlingVelocity();
	setOnTouchListener(newOnTouchListener());
	newScroller();
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:23,代码来源:FlywheelView.java

示例3: init

import com.mob.tools.utils.ResHelper; //导入方法依赖的package包/类
private void init(Context context) {
	setCanceledOnTouchOutside(true);//触摸屏幕取消窗体
	setCancelable(true);//按返回键取消窗体
	Window window = getWindow();
	window.setWindowAnimations(ResHelper.getStyleRes(context, "BBS_AnimUpDown"));

	//setup view
	LinearLayout llItem = new LinearLayout(context);
	int padding = ResHelper.dipToPx(context, 30);
	llItem.setPadding(padding, padding, padding, padding);
	llItem.setBackgroundResource(ResHelper.getBitmapRes(context, "bbs_bg_warning_dialog"));
	llItem.setOrientation(LinearLayout.VERTICAL);
	ImageView ivClose = new ImageView(context);
	ivClose.setImageResource(ResHelper.getBitmapRes(context, "bbs_ic_warning_error"));
	LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
	llp.gravity = Gravity.CENTER_HORIZONTAL;
	llItem.addView(ivClose, llp);

	tvWarning = new TextView(context);
	tvWarning.setTextSize(TypedValue.COMPLEX_UNIT_PX, ResHelper.dipToPx(context, 12));
	tvWarning.setTextColor(0xff3a4045);
	llp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
	llp.gravity = Gravity.CENTER_HORIZONTAL;
	llp.topMargin = ResHelper.dipToPx(context, 30);
	llItem.addView(tvWarning, llp);

	WindowManager.LayoutParams params = new WindowManager.LayoutParams(ResHelper.dipToPx(getContext(), 400), ViewGroup.LayoutParams.WRAP_CONTENT);
	params.gravity = Gravity.CENTER;
	window.setContentView(llItem, params);

	ivClose.setOnClickListener(new View.OnClickListener() {
		public void onClick(View v) {
			dismiss();
		}
	});
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:37,代码来源:WarningDialog.java

示例4: init

import com.mob.tools.utils.ResHelper; //导入方法依赖的package包/类
private void init(Context context) {
	tvEmpty = new TextView(context);
	int tvEmptySize = getResources().getDimensionPixelSize(ResHelper.getResId(context, "dimen", "bbs_empty_view_txt_size"));
	tvEmpty.setTextSize(TypedValue.COMPLEX_UNIT_PX, tvEmptySize);
	int padding = ResHelper.dipToPx(context, 10);
	tvEmpty.setPadding(padding, padding, padding, padding);
	int tvEmptyColor = getResources().getColor(ResHelper.getColorRes(context, "bbs_empty_view_txt_color"));
	tvEmpty.setTextColor(tvEmptyColor);
	tvEmpty.setId(ResHelper.getIdRes(context, "tvEmpty"));

	ivEmpty = new ImageView(context);
	ivEmpty.setScaleType(ImageView.ScaleType.CENTER);

	LayoutParams rlp = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
	rlp.addRule(CENTER_IN_PARENT, TRUE);
	addView(tvEmpty, rlp);

	rlp = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
	rlp.addRule(CENTER_HORIZONTAL, TRUE);
	rlp.addRule(ABOVE, tvEmpty.getId());
	addView(ivEmpty, rlp);

	OnClickListener ocl = new OnClickListener() {
		public void onClick(View view) {
			tvEmpty.setClickable(false);
			ivEmpty.setClickable(false);
			if (onRefreshClickListener != null) {
				onRefreshClickListener.onClick(view);
			}
		}
	};
	tvEmpty.setClickable(false);
	ivEmpty.setClickable(false);
	tvEmpty.setOnClickListener(ocl);
	ivEmpty.setOnClickListener(ocl);
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:37,代码来源:EmptyView.java

示例5: getView

import com.mob.tools.utils.ResHelper; //导入方法依赖的package包/类
public View getView(int position, View convertView, ViewGroup parent) {
	LinearLayout llContent = new LinearLayout(getContext());
	llContent.setOrientation(LinearLayout.VERTICAL);
	final GlideImageView aivIcon = new GlideImageView(getContext());
	int aivIconWidth = ResHelper.dipToPx(getContext(), 40);
	LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(aivIconWidth, aivIconWidth);
	llp.gravity = Gravity.CENTER_HORIZONTAL;
	llContent.addView(aivIcon, llp);

	TextView tvForumName = new TextView(getContext());
	tvForumName.setTextColor(0xff3a4045);
	tvForumName.setTextSize(TypedValue.COMPLEX_UNIT_PX, ResHelper.dipToPx(getContext(), 14));
	tvForumName.setEllipsize(TextUtils.TruncateAt.MIDDLE);
	tvForumName.setSingleLine();
	llp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
	llp.gravity = Gravity.CENTER_HORIZONTAL;
	llp.topMargin = ResHelper.dipToPx(getContext(), 8);
	llContent.addView(tvForumName, llp);

	ForumForum forum = getItem(position);
	if (forum != null) {
		tvForumName.setText(forum.name);
		if (!TextUtils.isEmpty(forum.forumPic)) {
			aivIcon.setExecuteRound(ResHelper.dipToPx(getContext(), 5));
			aivIcon.setScaleType(ImageView.ScaleType.CENTER_CROP);
		}
		aivIcon.execute(forum.forumPic, forum.fid == 0 ? defaultTotalForumPic : defaultForumPic);
	} else {
		aivIcon.setImageResource(defaultForumPic);
	}
	return llContent;
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:33,代码来源:ForumForumView.java

示例6: init

import com.mob.tools.utils.ResHelper; //导入方法依赖的package包/类
private void init(Context context) {
	chrysanthemum = initChrysanthemum(context);
	int px38 = ResHelper.dipToPx(getContext(), 19);
	LayoutParams lp = new LayoutParams(px38, px38);
	lp.addRule(RelativeLayout.CENTER_IN_PARENT);
	addView(chrysanthemum, lp);

	finish = new View(context);
	finish.setBackgroundResource(ResHelper.getBitmapRes(getContext(), "bbs_header_load_finished"));
	addView(finish, lp);
	finish.setVisibility(View.INVISIBLE);
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:13,代码来源:ChrysanthemumView.java

示例7: fromDp

import com.mob.tools.utils.ResHelper; //导入方法依赖的package包/类
/**
* 根据density转换设计的dp到目标机器,返回px大小
* @return 像素大小
*/
public static int fromDp(int dp) {
	int px = ResHelper.dipToPx(context, dp);
	return ResHelper.designToDevice(context, designedDensity, px);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:SizeHelper.java

示例8: init

import com.mob.tools.utils.ResHelper; //导入方法依赖的package包/类
private void init(Context context) {
	setCanceledOnTouchOutside(true);//触摸屏幕取消窗体
	setCancelable(true);//按返回键取消窗体
	Window window = getWindow();
	window.setWindowAnimations(ResHelper.getStyleRes(context, "BBS_AnimUpDown"));

	//setup view
	LinearLayout containLayout = new LinearLayout(context);
	containLayout.setOrientation(LinearLayout.VERTICAL);
	int leftPadding = ResHelper.dipToPx(context, 16);
	containLayout.setPadding(leftPadding, 0, leftPadding, leftPadding / 2);
	window.setContentView(containLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));

	if (listItems.size() > 0) {
		LinearLayout itemContainer = new LinearLayout(context);
		itemContainer.setOrientation(LinearLayout.VERTICAL);
		itemContainer.setBackgroundResource(ResHelper.getBitmapRes(context, "bbs_chooser_dialog_item_bg"));
		LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
		containLayout.addView(itemContainer, llp);

		//添加item
		int dividerHeight = context.getResources()
				.getDimensionPixelSize(ResHelper.getResId(context, "dimen", "bbs_chooser_dialog_divider_height"));
		int itemHeight = context.getResources().getDimensionPixelSize(ResHelper.getResId(context, "dimen", "bbs_chooser_dialog_item_height"));
		int txtSize = context.getResources().getDimensionPixelSize(ResHelper.getResId(context, "dimen", "bbs_chooser_dialog_txt_size"));
		int txtColor = context.getResources().getColor(ResHelper.getColorRes(context, "bbs_chooser_dialog_txt_color"));
		int length = listItems.size();
		tvItems = new SparseArray<TextView>(length);
		int topBgRes = ResHelper.getBitmapRes(context, "bbs_chooser_dialog_item_bg_top");
		int middleBgRes = ResHelper.getBitmapRes(context, "bbs_chooser_dialog_item_bg_middle");
		int bottomBgRes = ResHelper.getBitmapRes(context, "bbs_chooser_dialog_item_bg_bottom");
		for (int i = 0; i < length; i++) {
			int tag = i + 1;
			TextView tvItem = new TextView(context);
			tvItem.setTag(tag);
			tvItem.setGravity(Gravity.CENTER);
			tvItem.setTextColor(txtColor);
			tvItem.setTextSize(TypedValue.COMPLEX_UNIT_PX, txtSize);
			tvItem.setText(listItems.get(i));
			if (i == 0 && length > 1) {
				tvItem.setBackgroundResource(topBgRes);
			} else if (i == length - 1 && length > 1) {
				tvItem.setBackgroundResource(bottomBgRes);
			} else {
				tvItem.setBackgroundResource(middleBgRes);
			}
			llp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, itemHeight);
			itemContainer.addView(tvItem, llp);

			if (i < length - 1) {
				View vLine1 = new View(context);
				vLine1.setBackgroundColor(0xFFB7B7B7);
				llp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dividerHeight);
				itemContainer.addView(vLine1, llp);
			}
			tvItems.put(tag, tvItem);
		}

		TextView tvCancel = new TextView(context);
		tvCancel.setTag(0);
		tvCancel.setGravity(Gravity.CENTER);
		tvCancel.setTextColor(context.getResources().getColor(ResHelper.getColorRes(context, "bbs_chooser_dialog_cancel_txt_color")));
		tvCancel.setTextSize(TypedValue.COMPLEX_UNIT_PX, txtSize);
		tvCancel.setText(ResHelper.getStringRes(context, "bbs_cancel"));
		tvCancel.setBackgroundResource(ResHelper.getBitmapRes(context, "bbs_chooser_dialog_item_bg"));
		llp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, itemHeight);
		llp.topMargin = ResHelper.dipToPx(context, 10);
		containLayout.addView(tvCancel, llp);

		tvItems.put(0, tvCancel);
	}
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:73,代码来源:DefaultChooserDialog.java

示例9: setItemHeight

import com.mob.tools.utils.ResHelper; //导入方法依赖的package包/类
public void setItemHeight(int itemHeight) {
	this.itemHeight = itemHeight;
	if (this.itemHeight <= 0) {
		this.itemHeight = ResHelper.dipToPx(getContext(), 37);
	}
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:7,代码来源:FlywheelView.java

示例10: init

import com.mob.tools.utils.ResHelper; //导入方法依赖的package包/类
private void init(Context context) {
	setOrientation(VERTICAL);

	LinearLayout ll = new LinearLayout(context);
	int dp53 = ResHelper.dipToPx(context, 44);
	int dp15 = ResHelper.dipToPx(context, 15);
	ll.setPadding(0, 0, dp15, 0);
	LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, dp53);
	addView(ll, lp);

	tvTitle = new TextView(context);
	tvTitle.setMinEms(4);
	tvTitle.setTextColor(0xff3b3947);
	tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
	lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lp.leftMargin = dp15;
	lp.gravity = Gravity.CENTER_VERTICAL;
	ll.addView(tvTitle, lp);

	tvChoice = new TextView(context);
	tvChoice.setTextColor(0xff969696);
	tvChoice.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
	tvChoice.setText(ResHelper.getStringRes(context, "bbs_umssdk_default_unedit"));
	tvChoice.setGravity(Gravity.RIGHT);
	lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lp.gravity = Gravity.CENTER_VERTICAL;
	lp.weight = 1;
	ll.addView(tvChoice, lp);

	ivNext = new ImageView(context);
	ivNext.setImageResource(ResHelper.getBitmapRes(context, "bbssdk_umssdk_default_go_details"));
	lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lp.gravity = Gravity.CENTER_VERTICAL;
	lp.leftMargin = ResHelper.dipToPx(context, 5);
	ll.addView(ivNext, lp);
	ivNext.setVisibility(GONE);

	View vSep = new View(context);
	int resid = ResHelper.getBitmapRes(context, "bbssdk_umssdk_defalut_list_sep");
	vSep.setBackgroundDrawable(context.getResources().getDrawable(resid));
	lp = new LayoutParams(LayoutParams.MATCH_PARENT, 1);
	addView(vSep, lp);
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:44,代码来源:SingleChoiceView.java

示例11: init

import com.mob.tools.utils.ResHelper; //导入方法依赖的package包/类
private void init(Context context) {
	setBackgroundResource(ResHelper.getColorRes(context, "bbs_title_bg"));
	TypedValue outvalue = new TypedValue();
	getContext().getResources().getValue(ResHelper.getResId(context, "dimen", "bbs_title_bg_alpha"), outvalue, true);
	setAlpha(outvalue.getFloat());
	int titleHeight = getResources().getDimensionPixelSize(ResHelper.getResId(context, "dimen", "bbs_title_bar_height"));
	ivLeft = new ImageView(context);
	ivLeft.setScaleType(ScaleType.CENTER);
	LayoutParams lp = new LayoutParams(titleHeight, titleHeight);
	addView(ivLeft, lp);
	ivLeft.setVisibility(GONE);

	int avatarSize = ResHelper.dipToPx(getContext(), 28);
	if (avatarSize > titleHeight) {
		avatarSize = titleHeight;
	}
	ivAvatar = new GlideImageView(context);
	ivAvatar.setExecuteRound();
	lp = new LayoutParams(avatarSize, avatarSize);
	lp.leftMargin = (titleHeight - avatarSize) / 2;
	lp.topMargin = (titleHeight - avatarSize) / 2;
	addView(ivAvatar, lp);
	ivAvatar.setVisibility(GONE);

	int colorTvBtn = getResources().getColor(ResHelper.getColorRes(context, "bbs_title_txt_btn"));
	tvLeft = new TextView(context);
	tvLeft.setGravity(Gravity.CENTER);
	int paddingLeft = ResHelper.dipToPx(context, 10);
	tvLeft.setPadding(paddingLeft, 0, paddingLeft, 0);
	tvLeft.setSingleLine();
	tvLeft.setTextColor(colorTvBtn);
	int tvLeftSize = getResources().getDimensionPixelSize(ResHelper.getResId(context, "dimen", "bbs_title_left_txt_size"));
	tvLeft.setTextSize(TypedValue.COMPLEX_UNIT_PX, tvLeftSize);
	lp = new LayoutParams(LayoutParams.WRAP_CONTENT, titleHeight);
	lp.gravity = Gravity.LEFT;
	addView(tvLeft, lp);
	tvLeft.setVisibility(GONE);

	tvRight = new TextView(context);
	tvRight.setGravity(Gravity.CENTER);
	tvRight.setPadding(paddingLeft, 0, paddingLeft, 0);
	tvRight.setSingleLine();
	tvRight.setTextColor(colorTvBtn);
	int tvRightSize = getResources().getDimensionPixelSize(ResHelper.getResId(context, "dimen", "bbs_title_right_txt_size"));
	tvRight.setTextSize(TypedValue.COMPLEX_UNIT_PX, tvRightSize);
	lp = new LayoutParams(LayoutParams.WRAP_CONTENT, titleHeight);
	lp.gravity = Gravity.RIGHT;
	addView(tvRight, lp);
	tvRight.setVisibility(GONE);

	ivRight = new ImageView(context);
	ivRight.setScaleType(ScaleType.CENTER);
	lp = new LayoutParams(titleHeight, titleHeight);
	lp.gravity = Gravity.RIGHT;
	addView(ivRight, lp);
	ivRight.setVisibility(GONE);

	pbRight = new ProgressBar(context);
	pbRight.setIndeterminate(true);
	int drawableId = ResHelper.getBitmapRes(context, "bbs_anim_rotate");
	pbRight.setIndeterminateDrawable(context.getResources().getDrawable(drawableId));
	int pbHeight = ResHelper.dipToPx(context, 30);
	lp = new LayoutParams(pbHeight, pbHeight);
	lp.rightMargin = (titleHeight - pbHeight) / 2;
	lp.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL;
	addView(pbRight, lp);
	pbRight.setVisibility(GONE);

	viewCenter = getCenterView();
	lp = new LayoutParams(LayoutParams.MATCH_PARENT, titleHeight);
	lp.leftMargin = titleHeight;
	lp.rightMargin = titleHeight;
	addView(viewCenter, lp);
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:75,代码来源:TitleBar.java


注:本文中的com.mob.tools.utils.ResHelper.dipToPx方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。