本文整理汇总了Java中android.widget.TextView.setPaddingRelative方法的典型用法代码示例。如果您正苦于以下问题:Java TextView.setPaddingRelative方法的具体用法?Java TextView.setPaddingRelative怎么用?Java TextView.setPaddingRelative使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TextView
的用法示例。
在下文中一共展示了TextView.setPaddingRelative方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: UploadView
import android.widget.TextView; //导入方法依赖的package包/类
public UploadView(Context context, String uploadId, Bitmap bm, String title, String statusText, String pText, int progress) {
super(context);
idView = new TextView(context);
idView.setVisibility(View.GONE);
idView.setText(uploadId + "");
imageView = new ImageView(context);
imageView.setImageBitmap(bm);
imageView.setBackgroundColor(0xFF666666);
imageView.setId(VIDEOIMAGE_ID);
titleView = new TextView(context);
titleView.setText(title);
titleView.setTextColor(0xFF000000);
titleView.setId(TITLEVIEW_ID);
titleView.setPaddingRelative(5, 5, 0, 0);
statusTextView = new TextView(context);
statusTextView.setText(statusText);
statusTextView.setTextColor(0xFF000000);
statusTextView.setId(STATUSVIEW_ID);
statusTextView.setPaddingRelative(5, 5, 0, 0);
statusTextView.setTextColor(Color.GRAY);
progressTextView = new TextView(context);
progressTextView.setText(pText);
progressTextView.setTextColor(0xFF000000);
progressTextView.setId(PROGRESSTEXT_ID);
progressTextView.setPaddingRelative(5, 5, 0, 0);
progressTextView.setTextColor(Color.GRAY);
progressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
progressBar.setMax(100);
progressBar.setIndeterminate(false);
progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar));
progressBar.setId(PROGRESSBAR_ID);
progressBar.setPaddingRelative(5, 0, 0, 0);
progressBar.setProgress(progress);
/**
*
* + + + + title
* + img + 0M / 0M
* + + 下载中
* + + + + ********progress**************
*
* */
//左侧
LayoutParams imageLayoutParams = new LayoutParams(ParamsUtil.dpToPx(context, 75), ParamsUtil.dpToPx(context, 75));
imageLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
//位于图片右侧
LayoutParams titleLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
titleLayoutParams.addRule(RelativeLayout.RIGHT_OF, VIDEOIMAGE_ID);
//位于标题下方
LayoutParams statusLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
statusLayoutParams.addRule(RelativeLayout.BELOW, TITLEVIEW_ID);
statusLayoutParams.addRule(RelativeLayout.RIGHT_OF, VIDEOIMAGE_ID);
//位于状态下方
LayoutParams progressTextParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
progressTextParams.addRule(RelativeLayout.BELOW, STATUSVIEW_ID);
progressTextParams.addRule(RelativeLayout.RIGHT_OF, VIDEOIMAGE_ID);
//位于图片左侧,进度文本下方
LayoutParams progressBarLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, ParamsUtil.dpToPx(context, 7));
progressBarLayoutParams.addRule(RelativeLayout.RIGHT_OF, VIDEOIMAGE_ID);
progressBarLayoutParams.addRule(RelativeLayout.BELOW, PROGRESSTEXT_ID);
progressBarLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
addView(imageView, imageLayoutParams);
addView(titleView, titleLayoutParams);
addView(statusTextView, statusLayoutParams);
addView(progressTextView, progressTextParams);
addView(progressBar, progressBarLayoutParams);
setPadding(5, 5, 5, 5);
}