本文整理汇总了Java中android.widget.RelativeLayout.addView方法的典型用法代码示例。如果您正苦于以下问题:Java RelativeLayout.addView方法的具体用法?Java RelativeLayout.addView怎么用?Java RelativeLayout.addView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.RelativeLayout
的用法示例。
在下文中一共展示了RelativeLayout.addView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getView
import android.widget.RelativeLayout; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
RelativeLayout layoutView = new RelativeLayout(context);
TextView textView = new TextView(context);
textView.setTextSize(13);
textView.setText(itemList.get(position));
textView.setTag(position);
if (checkedPosition == position || itemList.size() == 1) {
// layoutView.setBackgroundColor(0x8033B5E5);
textView.setTextColor(context.getResources().getColor(R.color.rb_text_check));
} else {
textView.setTextColor(Color.WHITE);
}
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
layoutView.addView(textView, params);
layoutView.setMinimumHeight(ParamsUtil.dpToPx(context, 26));
return layoutView;
}
示例2: initLayout
import android.widget.RelativeLayout; //导入方法依赖的package包/类
public RelativeLayout initLayout() {
View v = getLayoutInflater(null).inflate(R.layout.apprunner_fragment, null);
// add main layout
mainLayout = (RelativeLayout) v.findViewById(R.id.main);
// set the parent
parentScriptedLayout = (RelativeLayout) v.findViewById(R.id.scriptedLayout);
liveCoding = new PLiveCodingFeedback(mContext);
mainLayout.addView(liveCoding.add());
infoLayout = (RelativeLayout) v.findViewById(R.id.infoLayout);
txtTitle = (TextView) v.findViewById(R.id.txtTitle);
txtSubtitle = (TextView) v.findViewById(R.id.txtSubtitle);
return mainLayout;
}
示例3: initWidgets
import android.widget.RelativeLayout; //导入方法依赖的package包/类
@Override
protected void initWidgets() {
super.initWidgets();
mLayoutBottom = (RelativeLayout) findViewById(R.id.kf5_bottom_layout);
mFeedBackDetailBottomView = new FeedBackDetailBottomView(mActivity);
mFeedBackDetailBottomView.setListener(this);
mETContent = layoutListener.getEditText();
mLayoutBottom.addView(mFeedBackDetailBottomView);
mListView = (ListView) findViewById(R.id.kf5_activity_feed_back_details_listview);
mListView.setOnScrollListener(this);
mListView.setOnItemLongClickListener(this);
mListView.addHeaderView(inflateHeaderView());
mBackImg = (ImageView) findViewById(R.id.kf5_return_img);
mBackImg.setOnClickListener(this);
mRightView = (TextView) findViewById(R.id.kf5_right_text_view);
mRightView.setOnClickListener(this);
}
示例4: initView
import android.widget.RelativeLayout; //导入方法依赖的package包/类
private void initView() {
// //动态添加webview,防止webview内存泄露
RelativeLayout layout_content= (RelativeLayout) findViewById(R.id.layout_content);
webView=new WebView(this);
webView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
layout_content.addView(webView);
// webView = (WebView) findViewById(R.id.webView);
layout_no_data = (RelativeLayout) findViewById(R.id.layout_no_data);
top_bar = (LinearLayout) findViewById(R.id.top_bar);
left_btn = (ImageView) findViewById(R.id.left_btn);
middleTitle = (TextView) findViewById(R.id.middleTitle);
rightBtn = (ImageView) findViewById(R.id.right_home_btn);
rightShareButton = (ImageView) findViewById(R.id.right_share_btn);
//设置webview相关设置
initWebView(webView);
//设置webview相关事件
initWebEvent(webView);
}
示例5: updateIndicator
import android.widget.RelativeLayout; //导入方法依赖的package包/类
public void updateIndicator(int count) {
if(dotViews == null){
return;
}
for(int i = 0 ; i < dotViews.size() ; i++){
if(i >= count){
dotViews.get(i).setVisibility(GONE);
((View)dotViews.get(i).getParent()).setVisibility(GONE);
}
else {
dotViews.get(i).setVisibility(VISIBLE);
((View)dotViews.get(i).getParent()).setVisibility(VISIBLE);
}
}
if(count > dotViews.size()){
int diff = count - dotViews.size();
for(int i = 0 ; i < diff ; i++){
RelativeLayout rl = new RelativeLayout(context);
LayoutParams params = new LinearLayout.LayoutParams(dotHeight,dotHeight);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
ImageView imageView = new ImageView(context);
imageView.setImageBitmap(unselectedBitmap);
rl.addView(imageView, layoutParams);
rl.setVisibility(View.GONE);
imageView.setVisibility(View.GONE);
this.addView(rl, params);
dotViews.add(imageView);
}
}
}
示例6: DProgressBar
import android.widget.RelativeLayout; //导入方法依赖的package包/类
public static ProgressBar DProgressBar(Context context) {
ViewGroup layout = (ViewGroup) ((Activity) context).findViewById(android.R.id.content).getRootView();
ProgressBar mProgressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
mProgressBar.setIndeterminate(true);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
RelativeLayout rl = new RelativeLayout(context);
rl.setGravity(Gravity.CENTER);
rl.addView(mProgressBar);
layout.addView(rl, params);
return mProgressBar;
}
示例7: onCreate
import android.widget.RelativeLayout; //导入方法依赖的package包/类
public void onCreate() {
super.onCreate();
int screenHeight = ResHelper.getScreenHeight(activity);
float ratio = ((float) screenHeight) / DESIGN_SCREEN_HEIGHT;
maxBodyHeight = 0;
llPage = new LinearLayout(activity);
llPage.setOrientation(LinearLayout.VERTICAL);
activity.setContentView(llPage);
rlTitle = new RelativeLayout(activity);
rlTitle.setBackgroundColor(0xffe6e9ec);
int titleHeight = (int) (DESIGN_TITLE_HEIGHT * ratio);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, titleHeight);
llPage.addView(rlTitle, lp);
initTitle(rlTitle, ratio);
RelativeLayout rlBody = new RelativeLayout(activity);
rlBody.setBackgroundColor(0xffffffff);
lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
llPage.addView(rlBody, lp);
initBody(rlBody, ratio);
LinearLayout llShadow = new LinearLayout(activity);
llShadow.setOrientation(LinearLayout.VERTICAL);
rlBody.addView(llShadow, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
initShadow(llShadow, ratio);
llBottom = new LinearLayout(activity);
llBottom.setOrientation(LinearLayout.VERTICAL);
lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
llPage.addView(llBottom, lp);
initBottom(llBottom, ratio);
}
示例8: setupIndicator
import android.widget.RelativeLayout; //导入方法依赖的package包/类
public void setupIndicator(RelativeLayout indicator) {
this.indicator = indicator;
if (indicator == null) {
return;
}
if (indicator.getChildCount() > 0) {
indicator.removeAllViews();
}
ringList = new ArrayList<ImageView>();
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
LinearLayout ll = new LinearLayout(context);
ll.setLayoutParams(lp);
indicator.addView(ll);
LinearLayout.LayoutParams lpp = new LinearLayout.LayoutParams(DisplayUtil.dp2px(7), DisplayUtil.dp2px(7));
for (int i = 0; i < pageCount; i++) {
ImageView iv = new ImageView(context);
iv.setLayoutParams(lpp);
if (pageCount == 1) {
iv.setBackgroundResource(R.drawable.ring_imageview_select);
}
if (i > 0) {
lpp.leftMargin = DisplayUtil.dp2px(3);
}
ringList.add(iv);
ll.addView(iv);
}
}
示例9: onCreateView
import android.widget.RelativeLayout; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
final RelativeLayout view = (RelativeLayout) inflater.inflate(R.layout.map_google, container, false);
registerListeners(view);
if (! myLocationEnabled)
view.findViewById(R.id.mapLocateButton).setVisibility(View.INVISIBLE);
final int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity());
if (errorCode != ConnectionResult.SUCCESS)
{
final Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode, getActivity(), 0);
errorDialog.show();
getFragmentManager().popBackStack();
return view;
}
View mapView = super.onCreateView(inflater, container, savedInstanceState);
final RelativeLayout mapViewContainer = (RelativeLayout) view.findViewById(R.id.mapViewContainer);
mapViewContainer.addView(mapView);
ProgressBar progessBar = new ProgressBar(getActivity());
final RelativeLayout.LayoutParams layoutParams =
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, 1);
progessBar.setLayoutParams(layoutParams);
progessBar.setVisibility(View.GONE);
view.addView(progessBar);
return view;
}
示例10: initView
import android.widget.RelativeLayout; //导入方法依赖的package包/类
private void initView() {
RelativeLayout layout = new RelativeLayout(mContext);
RelativeLayout.LayoutParams params =
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.CENTER_HORIZONTAL);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
mGood = new TextView(mContext);
mGood.setIncludeFontPadding(false);
mGood.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mTextSize);
mGood.setTextColor(ContextCompat.getColor(mContext, mTextColor));
mGood.setText(mText);
mGood.setLayoutParams(params);
layout.addView(mGood);
setContentView(layout);
int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
mGood.measure(w, h);
setWidth(mGood.getMeasuredWidth());
setHeight(mDistance + mGood.getMeasuredHeight());
setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
setFocusable(false);
setTouchable(false);
setOutsideTouchable(false);
mAnimationSet = createAnimation();
}
示例11: myAddView
import android.widget.RelativeLayout; //导入方法依赖的package包/类
private void myAddView(View view) {
if (view instanceof FImageView && ((FImageView) view).centered) {
// TODO: 17-2-13 any more efficient way?
RelativeLayout rl = new RelativeLayout(mContext);
RelativeLayout.LayoutParams rlLp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
rlLp.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
rl.addView(view);
rl.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
addView(rl);
} else {
addView(view);
}
}
示例12: initBody
import android.widget.RelativeLayout; //导入方法依赖的package包/类
private void initBody(RelativeLayout rlBody, float ratio) {
svContent = new ScrollView(activity);
rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
LinearLayout llContent = new LinearLayout(activity);
llContent.setOrientation(LinearLayout.VERTICAL);
svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
etContent = new EditText(activity);
int padding = (int) (DESIGN_LEFT_PADDING * ratio);
etContent.setPadding(padding, padding, padding, padding);
etContent.setBackgroundDrawable(null);
etContent.setTextColor(0xff3b3b3b);
etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
etContent.setText(sp.getText());
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
llContent.addView(etContent, lp);
etContent.addTextChangedListener(this);
rlThumb = new RelativeLayout(activity);
rlThumb.setBackgroundColor(0xff313131);
int thumbWidth = (int) (DESIGN_THUMB_HEIGHT * ratio);
int xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT * ratio);
lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth);
lp.leftMargin = lp.rightMargin = lp.bottomMargin = lp.topMargin = padding;
llContent.addView(rlThumb, lp);
aivThumb = new AsyncImageView(activity) {
public void onImageGot(String url, Bitmap bm) {
thumb = bm;
super.onImageGot(url, bm);
}
};
aivThumb.setScaleToCropCenter(true);
RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth);
rlThumb.addView(aivThumb, rllp);
aivThumb.setOnClickListener(this);
initThumb(aivThumb);
xvRemove = new XView(activity);
xvRemove.setRatio(ratio);
rllp = new RelativeLayout.LayoutParams(xWidth, xWidth);
rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
rlThumb.addView(xvRemove, rllp);
xvRemove.setOnClickListener(this);
}
示例13: initTitle
import android.widget.RelativeLayout; //导入方法依赖的package包/类
private void initTitle(RelativeLayout rlTitle, float ratio) {
tvCancel = new TextView(activity);
tvCancel.setTextColor(0xff3b3b3b);
tvCancel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
tvCancel.setGravity(Gravity.CENTER);
int resId = ResHelper.getStringRes(activity, "ssdk_oks_cancel");
if (resId > 0) {
tvCancel.setText(resId);
}
int padding = (int) (DESIGN_LEFT_PADDING * ratio);
tvCancel.setPadding(padding, 0, padding, 0);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
rlTitle.addView(tvCancel, lp);
tvCancel.setOnClickListener(this);
TextView tvTitle = new TextView(activity);
tvTitle.setTextColor(0xff3b3b3b);
tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
tvTitle.setGravity(Gravity.CENTER);
resId = ResHelper.getStringRes(activity, "ssdk_oks_multi_share");
if (resId > 0) {
tvTitle.setText(resId);
}
lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
lp.addRule(RelativeLayout.CENTER_IN_PARENT);
rlTitle.addView(tvTitle, lp);
tvShare = new TextView(activity);
tvShare.setTextColor(0xffff6d11);
tvShare.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
tvShare.setGravity(Gravity.CENTER);
resId = ResHelper.getStringRes(activity, "ssdk_oks_share");
if (resId > 0) {
tvShare.setText(resId);
}
tvShare.setPadding(padding, 0, padding, 0);
lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
rlTitle.addView(tvShare, lp);
tvShare.setOnClickListener(this);
}
示例14: initTitle
import android.widget.RelativeLayout; //导入方法依赖的package包/类
private void initTitle(RelativeLayout rlTitle, float ratio) {
tvCancel = new TextView(activity);
tvCancel.setTextColor(0xff3b3b3b);
tvCancel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
tvCancel.setGravity(Gravity.CENTER);
int resId = ResHelper.getStringRes(activity, "ssdk_oks_cancel");
if (resId > 0) {
tvCancel.setText(resId);
}
int padding = (int) (DESIGN_LEFT_PADDING * ratio);
tvCancel.setPadding(padding, 0, padding, 0);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
rlTitle.addView(tvCancel, lp);
tvCancel.setOnClickListener(this);
TextView tvTitle = new TextView(activity);
tvTitle.setTextColor(0xff3b3b3b);
tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
tvTitle.setGravity(Gravity.CENTER);
resId = ResHelper.getStringRes(activity, "ssdk_oks_contacts");
if (resId > 0) {
tvTitle.setText(resId);
}
lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
lp.addRule(RelativeLayout.CENTER_IN_PARENT);
rlTitle.addView(tvTitle, lp);
tvConfirm = new TextView(activity);
tvConfirm.setTextColor(0xffff6d11);
tvConfirm.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
tvConfirm.setGravity(Gravity.CENTER);
resId = ResHelper.getStringRes(activity, "ssdk_oks_confirm");
if (resId > 0) {
tvConfirm.setText(resId);
}
tvConfirm.setPadding(padding, 0, padding, 0);
lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
rlTitle.addView(tvConfirm, lp);
tvConfirm.setOnClickListener(this);
}
示例15: initBody
import android.widget.RelativeLayout; //导入方法依赖的package包/类
private void initBody(RelativeLayout rlBody, float ratio) {
svContent = new ScrollView(activity);
rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
LinearLayout llContent = new LinearLayout(activity);
llContent.setOrientation(LinearLayout.HORIZONTAL);
svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
etContent = new EditText(activity);
int padding = (int) (DESIGN_LEFT_PADDING * ratio);
etContent.setPadding(padding, padding, padding, padding);
etContent.setBackgroundDrawable(null);
etContent.setTextColor(0xff3b3b3b);
etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
etContent.setText(sp.getText());
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT);
lp.weight = 1;
llContent.addView(etContent, lp);
etContent.addTextChangedListener(this);
rlThumb = new RelativeLayout(activity);
rlThumb.setBackgroundColor(0xff313131);
int thumbWidth = (int) (DESIGN_THUMB_HEIGHT_L * ratio);
int xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT_L * ratio);
lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth);
lp.rightMargin = lp.bottomMargin = lp.topMargin = padding;
llContent.addView(rlThumb, lp);
aivThumb = new AsyncImageView(activity) {
public void onImageGot(String url, Bitmap bm) {
thumb = bm;
super.onImageGot(url, bm);
}
};
aivThumb.setScaleToCropCenter(true);
RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth);
rlThumb.addView(aivThumb, rllp);
aivThumb.setOnClickListener(this);
initThumb(aivThumb);
xvRemove = new XView(activity);
xvRemove.setRatio(ratio);
rllp = new RelativeLayout.LayoutParams(xWidth, xWidth);
rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
rlThumb.addView(xvRemove, rllp);
xvRemove.setOnClickListener(this);
}