本文整理汇总了Java中android.widget.RelativeLayout类的典型用法代码示例。如果您正苦于以下问题:Java RelativeLayout类的具体用法?Java RelativeLayout怎么用?Java RelativeLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RelativeLayout类属于android.widget包,在下文中一共展示了RelativeLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setCenterView
import android.widget.RelativeLayout; //导入依赖的package包/类
/**
* 在 TopBar 的中间添加 View,如果此前已经有 View 通过该方法添加到 TopBar,则旧的View会被 remove
*
* @param view 要添加到TopBar中间的View
*/
public void setCenterView(View view) {
if (mCenterView == view) {
return;
}
if (mCenterView != null) {
removeView(mCenterView);
}
mCenterView = view;
LayoutParams params = (LayoutParams) mCenterView.getLayoutParams();
if (params == null) {
params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
}
params.addRule(RelativeLayout.CENTER_IN_PARENT);
addView(view, params);
}
示例2: onActivityResult
import android.widget.RelativeLayout; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
mCurrentPhotoPath = data.getStringExtra(ValueHelper.TAKEN_IMAGE_PATH);
if (mCurrentPhotoPath != null) {
((RelativeLayout)getActivity().findViewById(R.id.fragment_note)).setVisibility(View.VISIBLE);
setPic();
}
} else if (resultCode == Activity.RESULT_CANCELED) {
// if (((RelativeLayout)getActivity().findViewById(R.id.fragment_new_tree)).getVisibility() != View.VISIBLE) {
// getActivity().getSupportFragmentManager().popBackStack();
// }
}
}
示例3: setTitleStyleUI
import android.widget.RelativeLayout; //导入依赖的package包/类
private void setTitleStyleUI() {
if (titles.size() != imageUrls.size()) {
throw new RuntimeException("[Banner] --> The number of titles and images is different");
}
if (titleBackground != -1) {
titleView.setBackgroundColor(titleBackground);
}
if (titleHeight != -1) {
titleView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, titleHeight));
}
if (titleTextColor != -1) {
bannerTitle.setTextColor(titleTextColor);
}
if (titleTextSize != -1) {
bannerTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleTextSize);
}
if (titles != null && titles.size() > 0) {
bannerTitle.setText(titles.get(0));
bannerTitle.setVisibility(View.VISIBLE);
titleView.setVisibility(View.VISIBLE);
}
}
示例4: ViewHolder
import android.widget.RelativeLayout; //导入依赖的package包/类
public ViewHolder(final View itemView) {
super(itemView);
tv_warning_export_invoice_number = (AlwaysMarqueeTextView) itemView.findViewById(R.id.tv_warning_export_invoice_number);
tv_warning_foreign_businessman = (AlwaysMarqueeTextView) itemView.findViewById(R.id.tv_warning_foreign_businessman);
tv_warning_invoice_unit = (AppCompatTextView) itemView.findViewById(R.id.tv_warning_invoice_unit);
tv_warning_amount = (AppCompatTextView) itemView.findViewById(R.id.tv_warning_amount);
tv_warning_invoice_date = (AppCompatTextView) itemView.findViewById(R.id.tv_warning_invoice_date);
tv_warning_declare_date = (AppCompatTextView) itemView.findViewById(R.id.tv_warning_declare_date);
tv_warning_approve_expiration_date = (AppCompatTextView) itemView.findViewById(R.id.tv_warning_approve_expiration_date);
tv_warning_order_serial_number = (AppCompatTextView) itemView.findViewById(R.id.tv_warning_order_serial_number);
tv_warning_po_number = (AppCompatTextView) itemView.findViewById(R.id.tv_warning_po_number);
tv_warning_create_date = (AppCompatTextView) itemView.findViewById(R.id.tv_warning_create_date);
rl_content = (RelativeLayout) itemView.findViewById(R.id.rl_content);
rl_content.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
示例5: ComplexButton
import android.widget.RelativeLayout; //导入依赖的package包/类
public ComplexButton(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
LayoutInflater.from(context).inflate(R.layout.complex_button, this);
button = (RelativeLayout) findViewById(R.id.complex_button_body);
rightArrow = (ImageView) findViewById(R.id.complex_button_item_right_arrow);
circleImageView = (CircleImageView) findViewById(R.id.complex_button_item_image);
itemName = (TextView) findViewById(R.id.complex_button_item_name);
detail = (TextView) findViewById(R.id.complex_button_item_detail);
redDot = (ImageView) findViewById(R.id.complex_button_red_dot);
redDot.setVisibility(GONE);
setButtonClickable(true);
button.setLongClickable(true);
button.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
return true;
}
});
selectType(TYPE_IMAGE_ROUND);
}
示例6: MyViewHolder
import android.widget.RelativeLayout; //导入依赖的package包/类
public MyViewHolder(final View itemView) {
super(itemView);
rl_cb_item = (RelativeLayout) itemView.findViewById(R.id.rl_cb_item);
cb_item = (CheckBox) itemView.findViewById(R.id.cb_item);
iv_item_goods = (ImageView) itemView.findViewById(R.id.iv_item_goods);
iv_item_plus = (ImageView) itemView.findViewById(R.id.iv_item_plus);
iv_item_reduce = (ImageView) itemView.findViewById(R.id.iv_item_reduce);
iv_csb_jifen = (ImageView) itemView.findViewById(R.id.iv_csb_jifen);
iv_text_csb_jifen = (ImageView) itemView.findViewById(R.id.iv_text_csb_jifen);
tv_item_name = (TextView) itemView.findViewById(R.id.tv_item_name);
tv_item_price_one = (TextView) itemView.findViewById(R.id.tv_item_price_one);
tv_item_type = (TextView) itemView.findViewById(R.id.tv_item_type);
tv_item_price_add = (TextView) itemView.findViewById(R.id.tv_item_price_add);
tv_item_num = (TextView) itemView.findViewById(R.id.tv_item_num);
// dl_item_cart = (DrawerLayout) itemView.findViewById(R.id.dl_item_cart);
tv_item_cart_delete = (TextView) itemView.findViewById(R.id.tv_item_cart_delete);
}
示例7: DiaryPageContentView
import android.widget.RelativeLayout; //导入依赖的package包/类
/**
* 只允许new View的形式创建
*/
public DiaryPageContentView(Context context, int teamId, int year, int week) {
this.teamId = teamId;
this.year = year;
this.week = week;
this.cxt = (Activity) context;
rootView = (RelativeLayout) View.inflate(context,
R.layout.pager_item_diary, null);
listview = (ListView) rootView.findViewById(R.id.diary_listview);
pullHeadView = (SwipeRefreshLayout) rootView
.findViewById(R.id.swiperefreshlayout);
errorLayout = (EmptyLayout) rootView.findViewById(R.id.error_layout);
adapter = new TeamDiaryListAdapter(cxt, null);
initView();
requestData(true);
}
示例8: init
import android.widget.RelativeLayout; //导入依赖的package包/类
private void init(View view) {
countryName = (TextView) view.findViewById(R.id.textView11);
if( MainActivity.locationInfo != null)
countryName.setText(getResources().getConfiguration().locale.getDisplayLanguage()
.equals("العربية") ? ConfigPreferences.getLocationConfig(getContext()).name_english :
ConfigPreferences.getLocationConfig(getContext()).name);
Quibladegree = (TextView) view.findViewById(R.id.textView12);
Quibladegree.setText("Qibla direction from North: "+ ConfigPreferences.getQuibla(getContext()));
indicator = (ImageView) view.findViewById(R.id.imageView2);
compass = (RelativeLayout) view.findViewById(R.id.compassContainer);
mSensorManager = (SensorManager) getContext().getSystemService(getContext().SENSOR_SERVICE);
RotateAnimation ra = new RotateAnimation(currentDegree, MainActivity.quiblaDegree,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
ra.setDuration(400);
ra.setFillAfter(true);
indicator.startAnimation(ra);
}
示例9: onBindViewHolder
import android.widget.RelativeLayout; //导入依赖的package包/类
@Override
public void onBindViewHolder(WallpViewHolder holder, int position) {
Hit photo = this.hit.get(position);
RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) holder.discWallp.getLayoutParams();
float height =photo.getPreviewHeight();
float width = photo.getPreviewWidth();
float ratio = height/width ;
rlp.height = (int) (rlp.width * ratio);
holder.discWallp.setLayoutParams(rlp);
holder.discWallp.setRatio(ratio);
File file = new File(Environment.getExternalStoragePublicDirectory("/"+R.string.app_name), photo.getId()+context.getResources().getString(R.string.jpg));
Picasso.with(context)
.load(file)
.placeholder(R.drawable.plh)
.into(holder.discWallp);
}
示例10: onCreate
import android.widget.RelativeLayout; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tvPulsa = (TextView) findViewById(R.id.tvPulsa);
rl = (RelativeLayout) findViewById(R.id.activity_main);
animation = AnimationUtils.loadAnimation(this, R.anim.fadeinout);
tvPulsa.startAnimation(animation);
rl.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Intent intent = new Intent(MainActivity.this, MenuActivity.class);
startActivity(intent);
return true;
}
});
}
示例11: ViewHolder
import android.widget.RelativeLayout; //导入依赖的package包/类
public ViewHolder(View itemView, Context c) {
super(itemView);
rlContactRow = (RelativeLayout) itemView.findViewById(R.id.rlContactRow);
ivContactImage = (ImageView) itemView.findViewById(R.id.ivContactImage);
tvContactName = (TextView) itemView.findViewById(R.id.tvContactName);
tvAffiliation = (TextView) itemView.findViewById(R.id.tvAffiliation);
rlContactRow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(!StringUtils.isNullOrEmpty(member.getAffiliation().val()) && StringUtils.safeEquals(member.getAffiliation().val(), ChatRoom.Affiliation.ADMIN.val()) ||
StringUtils.safeEquals(member.getAffiliation().val(), ChatRoom.Affiliation.OWNER.val())){
ChatRoom.ChatRoomMember m = memberList.get(getAdapterPosition());
if(!StringUtils.safeEquals(member.getUserJID().getBareJID(), m.getUserJID().getBareJID())){
showRemoveParticipantAlert(member.getUserJID(), getAdapterPosition());
}
}
}
});
}
示例12: initView
import android.widget.RelativeLayout; //导入依赖的package包/类
private void initView(Context context) {
rootView = View.inflate(context, R.layout.widget_hor_controller, this);
layout_topbar = (RelativeLayout) findViewById(R.id.layout_topbar);
img_btn_back = (ImageView) findViewById(R.id.img_btn_back);
top_ll = (LinearLayout) findViewById(R.id.top_ll);
check_gift_switch = (CheckBox) findViewById(R.id.check_gift_switch);
txt_btn_clarity = (TextView) findViewById(R.id.txt_btn_clarity);
check_focus = (CheckBox) findViewById(R.id.check_focus);
img_btn_share = (ImageView) findViewById(R.id.img_btn_share);
txt_btn_describe = (TextView) findViewById(R.id.txt_btn_describe);
txt_get_seed = (TextView) findViewById(R.id.txt_get_seed);
lv_quality = (ListView) findViewById(R.id.lv_quality);
tv_volume_brightness = (TextView) findViewById(R.id.tv_volume_brightness);
layout_bottom_thelive = (LinearLayout) findViewById(R.id.layout_bottom_thelive);
player_switch = (CheckBox) findViewById(R.id.rad_btn_player_switch);
img_btn_refresh = (ImageView) findViewById(R.id.img_btn_refresh);
txt_btn_hot_word = (ImageView) findViewById(R.id.txt_btn_hot_word);
ediit_comment = (EditText) findViewById(R.id.ediit_comment);
img_btn_send = (ImageView) findViewById(R.id.img_btn_send);
rad_btn_danmu_switch = (CheckBox) findViewById(R.id.rad_btn_danmu_switch);
img_btn_gift = (ImageView) findViewById(R.id.img_btn_gift);
}
示例13: setupDialog
import android.widget.RelativeLayout; //导入依赖的package包/类
@Override
public void setupDialog(Dialog dialog, int style) {
View contentView = View.inflate(getContext(), R.layout.filter_sample_view, null);
RelativeLayout rl_content = (RelativeLayout) contentView.findViewById(R.id.rl_content);
LinearLayout ll_buttons = (LinearLayout) contentView.findViewById(R.id.ll_buttons);
contentView.findViewById(R.id.btn_close).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
closeFilter("closed");
}
});
//params to set
setAnimationDuration(600); //optional; default 500ms
setPeekHeight(300); // optional; default 400dp
setCallbacks((Callbacks) getActivity()); //optional; to get back result
setViewgroupStatic(ll_buttons); // optional; layout to stick at bottom on slide
// setViewPager(vp_types); //optional; if you use viewpager that has scrollview
setViewMain(rl_content); //necessary; main bottomsheet view
setMainContentView(contentView); // necessary; call at end before super
super.setupDialog(dialog, style); //call super at last
}
示例14: init
import android.widget.RelativeLayout; //导入依赖的package包/类
private void init(Context context) {
mContainerView = LayoutInflater.from(context).inflate(R.layout.widget_searchbar,this,false);
search_img_bt = (ImageButton) mContainerView.findViewById(R.id.search_img_bt);
search_edit_content = (RelativeLayout) mContainerView.findViewById(R.id.search_edit_content);
search_edit = (EditText) mContainerView.findViewById(R.id.search_edit);
search_tv = (TextView) mContainerView.findViewById(R.id.search_tv);
search_clear = (ImageView) mContainerView.findViewById(R.id.search_clear);
measureView(mContainerView);
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,
mContainerView.getMeasuredHeight());
addView(mContainerView, params);
if (isInterceptChild) {
search_img_bt.setVisibility(GONE);
search_tv.setVisibility(GONE);
} else {
search_img_bt.setVisibility(VISIBLE);
search_tv.setVisibility(VISIBLE);
}
}
示例15: ProgrammedRepeatingTaskViewHolder
import android.widget.RelativeLayout; //导入依赖的package包/类
public ProgrammedRepeatingTaskViewHolder(View itemView, ViewHolderClickListener listener) {
super(itemView);
mClickListener = listener;
mContainer = (RelativeLayout) itemView.findViewById(R.id.item_task_programmed_repeating_container);
mCategoryIcon = (ImageView) itemView.findViewById(R.id.item_task_programmed_repeating_category_icon);
mAttachmentList = (ImageView) itemView.findViewById(R.id.item_task_programmed_repeating_attachment_list);
mAttachmentLink = (ImageView) itemView.findViewById(R.id.item_task_programmed_repeating_attachment_link);
mAttachmentAudio = (ImageView) itemView.findViewById(R.id.item_task_programmed_repeating_attachment_audio);
mAttachmentImage = (ImageView) itemView.findViewById(R.id.item_task_programmed_repeating_attachment_image);
mAttachmentText = (ImageView) itemView.findViewById(R.id.item_task_programmed_repeating_attachment_text);
mTitle = (TextView) itemView.findViewById(R.id.item_task_programmed_repeating_title);
mDescription = (TextView) itemView.findViewById(R.id.item_task_programmed_repeating_description);
mRepeat = (TextView) itemView.findViewById(R.id.item_task_programmed_repeating_repeat);
mTime = (TextView) itemView.findViewById(R.id.item_task_programmed_repeating_time);
mItemDecoration = itemView.findViewById(R.id.item_task_programmed_repeating_item_decoration);
}