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


Java ProgressBar.setPadding方法代码示例

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


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

示例1: create

import android.widget.ProgressBar; //导入方法依赖的package包/类
public static LinearLayout create(Context context) {
	LinearLayout root = new LinearLayout(context);
	ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
			ViewGroup.LayoutParams.WRAP_CONTENT);
	root.setLayoutParams(params);
	root.setOrientation(LinearLayout.VERTICAL);

	ProgressBar bar = new ProgressBar(context);
	LinearLayout.LayoutParams barParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	bar.setLayoutParams(barParams);
	SizeHelper.prepare(context);
	int padding = SizeHelper.fromPxWidth(20);
	bar.setPadding(padding, padding, padding, padding);

	root.addView(bar);

	return root;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:ProgressDialogLayout.java

示例2: DownloadView

import android.widget.ProgressBar; //导入方法依赖的package包/类
public DownloadView(Context context, String title, String statusInfo, String progressText, int progress) {
	super(context);
	
	titleView = new TextView(context);
	titleView.setText(title);
	titleView.setTextColor(0xFF000000);
	titleView.setId(TITLEVIEW_ID);
	titleView.setTextSize(15);
	titleView.setSingleLine();
	
	statusInfoView = new TextView(context);
	statusInfoView.setText(statusInfo);
	statusInfoView.setId(STATUSVIEW_ID);
	statusInfoView.setTextColor(0xFF000000);
	
	progressTextView = new TextView(context);
	progressTextView.setTextColor(0xFF000000);
	progressTextView.setId(PROGRESSTEXT_ID);
	progressTextView.setPadding(0, 10, 0, 0);
	progressTextView.setText(progressText);
	progressTextView.setTextColor(Color.GRAY);
	
	progressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
	
	progressBar.setMax(100);
	progressBar.setMinimumHeight(10);
	progressBar.setIndeterminate(false);
       progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar));
       progressBar.setPadding(0, 10, 0, 0);
       progressBar.setProgress(progress);
	
	 /**
        *  
        *  title               
        *  下载中
        *  0M / 0M                
        *  ********progress**************
        *  
        * */
	
	LayoutParams titleLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	titleLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
	addView(titleView, titleLayoutParams);
	
	LayoutParams statusInfoLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	statusInfoLayoutParams.addRule(RelativeLayout.BELOW, TITLEVIEW_ID);
	statusInfoLayoutParams.addRule(RelativeLayout.ALIGN_LEFT, TITLEVIEW_ID);
	addView(statusInfoView, statusInfoLayoutParams);
	
	LayoutParams progressTextLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	progressTextLayoutParams.addRule(RelativeLayout.BELOW, STATUSVIEW_ID);
	progressTextLayoutParams.addRule(RelativeLayout.ALIGN_LEFT, TITLEVIEW_ID);
	addView(progressTextView, progressTextLayoutParams);
	
	LayoutParams progressLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, 25);
	progressLayoutParams.addRule(RelativeLayout.BELOW, PROGRESSTEXT_ID);
	progressLayoutParams.addRule(RelativeLayout.ALIGN_LEFT, TITLEVIEW_ID);
	addView(progressBar, progressLayoutParams);
	
	setPadding(5, 5, 5, 5);
}
 
开发者ID:lbbniu,项目名称:CCDownload,代码行数:62,代码来源:DownloadView.java


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