當前位置: 首頁>>代碼示例>>Java>>正文


Java TextView.setPaddingRelative方法代碼示例

本文整理匯總了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);

}
 
開發者ID:lbbniu,項目名稱:CCDownload,代碼行數:81,代碼來源:UploadView.java


注:本文中的android.widget.TextView.setPaddingRelative方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。