本文整理汇总了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;
}
示例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);
}