本文整理汇总了Java中android.widget.ImageView.getLayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java ImageView.getLayoutParams方法的具体用法?Java ImageView.getLayoutParams怎么用?Java ImageView.getLayoutParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ImageView
的用法示例。
在下文中一共展示了ImageView.getLayoutParams方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ItemHolder
import android.widget.ImageView; //导入方法依赖的package包/类
public ItemHolder(View itemView) {
super(itemView);
int mWidth;
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
mWidth = (metrics.widthPixels) / Common.getNumberOfColms();
albumName = (TextView) itemView.findViewById(R.id.gridViewTitleText);
artistName = (TextView) itemView.findViewById(R.id.gridViewSubText);
albumart = (ImageView) itemView.findViewById(R.id.gridViewImage);
albumName.setTypeface(TypefaceHelper.getTypeface(itemView.getContext(), TypefaceHelper.FUTURA_BOOK));
artistName.setTypeface(TypefaceHelper.getTypeface(itemView.getContext(), TypefaceHelper.FUTURA_BOOK));
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) albumart.getLayoutParams();
params.width = mWidth;
params.height = mWidth;
albumart.setLayoutParams(params);
mOverFlow = (ImageView) itemView.findViewById(R.id.overflow);
mOverFlow.setOnClickListener(this);
itemView.setOnClickListener(this);
}
示例2: getDefaultWidth
import android.widget.ImageView; //导入方法依赖的package包/类
public int getDefaultWidth() {
ImageView imageView = this.mViewRef.get();
if (imageView != null) {
ViewGroup.LayoutParams params = imageView.getLayoutParams();
int width = 0;
if (this.checkActualViewSize && params != null && params.width != -2) {
width = imageView.getWidth();
}
if (width <= 0 && params != null) {
width = params.width;
}
if (width <= 0) {
width = getImageViewFieldValue(imageView, "mMaxWidth");
}
return width;
} else {
return 0;
}
}
示例3: MovieViewHolder
import android.widget.ImageView; //导入方法依赖的package包/类
public MovieViewHolder(View itemView) {
super(itemView);
movieCard = (CardView) itemView.findViewById(R.id.card_view_show_cast);
moviePosterImageView = (ImageView) itemView.findViewById(R.id.image_view_show_cast);
movieTitleTextView = (TextView) itemView.findViewById(R.id.text_view_title_show_cast);
castCharacterTextView = (TextView) itemView.findViewById(R.id.text_view_cast_character_show_cast);
moviePosterImageView.getLayoutParams().width = (int) (mContext.getResources().getDisplayMetrics().widthPixels * 0.31);
moviePosterImageView.getLayoutParams().height = (int) ((mContext.getResources().getDisplayMetrics().widthPixels * 0.31) / 0.66);
movieCard.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(mContext, MovieDetailActivity.class);
intent.putExtra(Constant.MOVIE_ID, mMovieCasts.get(getAdapterPosition()).getId());
mContext.startActivity(intent);
}
});
}
示例4: setContentView
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public void setContentView(int layoutResID) {
int statusHeight = Helper.getStatusHeight(this);
ToolBarHelper mToolBarHelper = new ToolBarHelper(this,layoutResID);
mToolbar = mToolBarHelper.getToolBar();
mToolbar.getLayoutParams().height += statusHeight;
mToolbar.setPadding(mToolbar.getPaddingLeft(), statusHeight, mToolbar.getPaddingRight(), mToolbar.getPaddingBottom());
setToolbarBack(ThemeStyle.Primary);
setContentView(mToolBarHelper.getContentView());
/*把 mToolbar 设置到Activity 中*/
setSupportActionBar(mToolbar);
/*自定义的一些操作*/
onCreateCustomToolBar(mToolbar);
mTitleView = (TextView) this.findViewById(R.id.toolbar_title);
mOkView = (ImageView) this.findViewById(R.id.toolbar_ok_btn);
if (mOkView != null){
mOkView.getLayoutParams().height = mOkView.getLayoutParams().width / 3;
mOkView.setOnClickListener(this);
}
mDeleteView = (ImageView) this.findViewById(R.id.toolbar_delete_btn);
if (mDeleteView != null){
mDeleteView.getLayoutParams().height = mDeleteView.getLayoutParams().width / 3;
mDeleteView.setOnClickListener(this);
}
}
示例5: convert
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void convert(final BaseViewHolder holder, final BeautyPhotoInfo item) {
final ImageView ivPhoto = holder.getView(R.id.iv_photo);
int photoHeight = StringUtils.calcPhotoHeight(item.getPixel(), mPhotoWidth);
// 接口返回的数据有像素分辨率,根据这个来缩放图片大小
final ViewGroup.LayoutParams params = ivPhoto.getLayoutParams();
params.width = mPhotoWidth;
params.height = photoHeight;
ivPhoto.setLayoutParams(params);
ImageLoader.loadFitCenter(mContext, item.getImgsrc(), ivPhoto, DefIconFactory.provideIcon());
holder.setText(R.id.tv_title, item.getTitle());
holder.getConvertView().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mFragment != null) {
BigPhotoActivity.launchForResult(mFragment, (ArrayList<BeautyPhotoInfo>) getData(), holder.getAdapterPosition());
} else {
BigPhotoActivity.launch(mContext, (ArrayList<BeautyPhotoInfo>) getData(), holder.getAdapterPosition());
}
}
});
}
示例6: createClock
import android.widget.ImageView; //导入方法依赖的package包/类
private void createClock() {
// get the ClockImageView
clockView = (ImageView) getActivity().getLayoutInflater().inflate(R.layout.view_clock, null);
clockView.setLayoutParams(new ViewGroup.LayoutParams(400, 400));
// Add into Screen
this.superContainer.addView(clockView);
// Set the position
RelativeLayout.LayoutParams layoutParams =
(RelativeLayout.LayoutParams) clockView.getLayoutParams();
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
layoutParams.setMargins(0, 0, 0, 100);
clockView.setLayoutParams(layoutParams);
ClockDrawable clockDrawable = new ClockDrawable(getResources());
clockDrawable.setAnimateDays(false);
clockView.setImageDrawable(clockDrawable);
clockView.setVisibility(View.VISIBLE);
}
示例7: FrameLayout
import android.widget.ImageView; //导入方法依赖的package包/类
private void addIconTabBådeTekstOgBillede(final int position, int resId, String url, String title) {
FrameLayout tabfl = new FrameLayout(getContext());
ImageView tabi = new ImageView(getContext());
tabi.setContentDescription(title);
//Log.d(title+" "+resId + " Kanallogo URL="+url);
if (resId==0) {
Picasso.with(tabi.getContext())
.load(url).placeholder(null)
.into(tabi);
tabi.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
tabi.setAdjustViewBounds(true);
tabi.setVisibility(View.GONE);
} else {
tabi.setImageResource(resId);
tabi.setVisibility(View.INVISIBLE);
}
TextView tabt = new TextView(getContext());
tabt.setText(title);
tabt.setTypeface(App.skrift_gibson);
tabt.setGravity(Gravity.CENTER);
tabt.setSingleLine();
tabfl.addView(tabi);
tabfl.addView(tabt);
LayoutParams lp = (LayoutParams) tabi.getLayoutParams();
lp.gravity=Gravity.CENTER;
lp.width=lp.height=ViewGroup.LayoutParams.MATCH_PARENT;
lp = (LayoutParams) tabt.getLayoutParams();
lp.width=lp.height=ViewGroup.LayoutParams.MATCH_PARENT;
lp.gravity=Gravity.CENTER;
addTab(position, tabfl);
}
示例8: adjustSize
import android.widget.ImageView; //导入方法依赖的package包/类
/**
* 调整图片的frame
*
* @param imageView
*/
public static void adjustSize(ImageView imageView) {
if (imageView != null && imageView.getLayoutParams() != null && imageView.getDrawable() != null) {
final int width = (imageView.getDrawable()).getIntrinsicWidth();
final int height = (imageView.getDrawable()).getIntrinsicHeight();
if (width != imageView.getLayoutParams().width || height != imageView.getLayoutParams().height) {
imageView.getLayoutParams().width = width;
imageView.getLayoutParams().height = height;
imageView.requestLayout();
}
}
}
示例9: ItemHolder
import android.widget.ImageView; //导入方法依赖的package包/类
public ItemHolder(View itemView) {
super(itemView);
int mWidth;
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
mWidth = (metrics.widthPixels) / Common.getNumberOfColms();
mArtistName = (TextView) itemView.findViewById(R.id.gridViewTitleText);
mDetails = (TextView) itemView.findViewById(R.id.gridViewSubText);
mArtistImage = (ImageView) itemView.findViewById(R.id.gridViewImage);
mArtistName.setTypeface(TypefaceHelper.getTypeface(itemView.getContext().getApplicationContext(), TypefaceHelper.FUTURA_BOOK));
mDetails.setTypeface(TypefaceHelper.getTypeface(itemView.getContext().getApplicationContext(), TypefaceHelper.FUTURA_BOOK));
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mArtistImage.getLayoutParams();
params.width = mWidth;
params.height = mWidth;
mArtistImage.setLayoutParams(params);
mOverFlowImageView = (ImageView) itemView.findViewById(R.id.overflow);
mOverFlowImageView.setVisibility(View.VISIBLE);
mOverFlowImageView.setOnClickListener(this);
itemView.setOnClickListener(this);
}
示例10: displayImage
import android.widget.ImageView; //导入方法依赖的package包/类
private void displayImage(ImageView image, String imageUrl, int width, int height, final
String bigUrl) {
image.getLayoutParams().width = width;
image.getLayoutParams().height = height;
this.imageLoader.displayImage(imageUrl, image, ImageLoaderOptions.global(this
.mDefaultImageDrawable), new AnimateFirstDisplayListener());
image.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(BaseTimelineAdapter.this.activity, LargeImageActivity
.class);
intent.putExtra("image_url", bigUrl);
BaseTimelineAdapter.this.activity.startActivity(intent);
}
});
}
示例11: getView
import android.widget.ImageView; //导入方法依赖的package包/类
public View getView(int position, View view, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
String name = themePrefs.getString(arrayId == 0 ? "chatBubbleStyle" : "chatCheckStyle", itemname[0]);
view = inflater.inflate(R.layout.imagelist, parent, false);
if(name.equals(itemname[position]) ){
view.setBackgroundColor(0xffd0d0d0);
} else{
view.setBackgroundColor(0xfff0f0f0);
}
TextView txtTitle = (TextView) view.findViewById(R.id.bubble_title);
ImageView inImageView = (ImageView) view.findViewById(R.id.bubble_in);
ImageView outImageView = (ImageView) view.findViewById(R.id.bubble_out);
txtTitle.setText(itemname[position]);
inImageView.setImageResource(imgid[position]);
outImageView.setImageResource(imgid[position + itemname.length]);
if(arrayId == 1){
view.setPadding(50, 0, 0, 0);
//inImageView.getLayoutParams().height = 70;
inImageView.getLayoutParams().width = 70;
inImageView.setColorFilter(0, PorterDuff.Mode.SRC_ATOP);
//outImageView.getLayoutParams().height = 70;
outImageView.getLayoutParams().width = 70;
outImageView.setColorFilter(0, PorterDuff.Mode.SRC_ATOP);
}
return view;
}
示例12: convert
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void convert(BaseViewHolder viewHolder, final T imageBean) {
ImageView imageView = viewHolder.getView(R.id.iv_welfare_image);
ViewGroup.LayoutParams params = imageView.getLayoutParams();
if(heights.containsKey(imageBean)){
params.height = heights.get(imageBean);
}else {
heights.put(imageBean, (int)(250 + Math.random() * 200));
params.height = heights.get(imageBean);
}
imageView.setLayoutParams(params);
ImageLoadUtil.loadCenterCrop(imageBean.getImgPath(), imageView);
if(TextUtils.isEmpty(imageBean.getImageDesc())) {
//(最小值+Math.random()*(最大值-最小值+1))
viewHolder.setText(R.id.tv_welfare_desc, Constant.poetry.get((int) (0 + Math.random() * (Constant.poetry.size() - 1 - 0 + 1))));
}else{
viewHolder.setText(R.id.tv_welfare_desc, imageBean.getImageDesc());
}
if(edit){
viewHolder.setVisible(R.id.cb_select, true);
viewHolder.setBackgroundRes(R.id.ll_bg, R.color.background_color);
viewHolder.setChecked(R.id.cb_select,map.containsKey(imageBean)?map.get(imageBean):false);
}else{
viewHolder.setVisible(R.id.cb_select, false);
viewHolder.setBackgroundRes(R.id.ll_bg,R.drawable.ripple_item_bg);
viewHolder.setChecked(R.id.cb_select,false);
}
((CheckBox)viewHolder.getView(R.id.cb_select)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
handleCheckedChanged(imageBean,isChecked);
}
});
}
示例13: FloatCamView
import android.widget.ImageView; //导入方法依赖的package包/类
public FloatCamView(FloatingCameraWindow window) {
super(window.mContext);
mWeakRef = new WeakReference<FloatingCameraWindow>(window);
// mLayoutInflater = LayoutInflater.from(context);
mLayoutInflater = (LayoutInflater) window.mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
FrameLayout body = (FrameLayout) this;
body.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
});
View floatView = mLayoutInflater.inflate(R.layout.cam_window_view, body, true);
mColorView = (ImageView) findViewById(R.id.imageView_c);
mFPSText = (TextView) findViewById(R.id.fps_textview);
mInfoText = (TextView) findViewById(R.id.info_textview);
mFPSText.setVisibility(View.GONE);
mInfoText.setVisibility(View.GONE);
int colorMaxWidth = (int) (mWindowWidth* window.mScaleWidthRatio);
int colorMaxHeight = (int) (mWindowHeight * window.mScaleHeightRatio);
mColorView.getLayoutParams().width = colorMaxWidth;
mColorView.getLayoutParams().height = colorMaxHeight;
mColorView.setScaleType(ImageView.ScaleType.FIT_XY);
}
示例14: InfoBarLayout
import android.widget.ImageView; //导入方法依赖的package包/类
/**
* Constructs a layout for the specified infobar. After calling this, be sure to set the
* message, the buttons, and/or the custom content using setMessage(), setButtons(), and
* setCustomContent().
*
* @param context The context used to render.
* @param infoBarView InfoBarView that listens to events.
* @param iconResourceId ID of the icon to use for the infobar.
* @param iconBitmap Bitmap for the icon to use, if the resource ID wasn't passed through.
* @param message The message to show in the infobar.
*/
public InfoBarLayout(Context context, InfoBarView infoBarView, int iconResourceId,
Bitmap iconBitmap, CharSequence message) {
super(context);
mControlLayouts = new ArrayList<InfoBarControlLayout>();
mInfoBarView = infoBarView;
// Cache resource values.
Resources res = getResources();
mSmallIconSize = res.getDimensionPixelSize(R.dimen.infobar_small_icon_size);
mSmallIconMargin = res.getDimensionPixelSize(R.dimen.infobar_small_icon_margin);
mBigIconSize = res.getDimensionPixelSize(R.dimen.infobar_big_icon_size);
mBigIconMargin = res.getDimensionPixelSize(R.dimen.infobar_big_icon_margin);
mMarginAboveButtonGroup =
res.getDimensionPixelSize(R.dimen.infobar_margin_above_button_row);
mMarginAboveControlGroups =
res.getDimensionPixelSize(R.dimen.infobar_margin_above_control_groups);
mPadding = res.getDimensionPixelOffset(R.dimen.infobar_padding);
mMinWidth = res.getDimensionPixelSize(R.dimen.infobar_min_width);
mAccentColor = ApiCompatibilityUtils.getColor(res, R.color.infobar_accent_blue);
// Set up the close button. Apply padding so it has a big touch target.
mCloseButton = new ImageButton(context);
mCloseButton.setId(R.id.infobar_close_button);
mCloseButton.setImageResource(R.drawable.btn_close);
TypedArray a = getContext().obtainStyledAttributes(
new int [] {R.attr.selectableItemBackground});
Drawable closeButtonBackground = a.getDrawable(0);
a.recycle();
mCloseButton.setBackground(closeButtonBackground);
mCloseButton.setPadding(mPadding, mPadding, mPadding, mPadding);
mCloseButton.setOnClickListener(this);
mCloseButton.setContentDescription(res.getString(R.string.infobar_close));
mCloseButton.setLayoutParams(new LayoutParams(0, -mPadding, -mPadding, -mPadding));
// Set up the icon.
if (iconResourceId != 0 || iconBitmap != null) {
mIconView = new ImageView(context);
if (iconResourceId != 0) {
mIconView.setImageResource(iconResourceId);
} else if (iconBitmap != null) {
mIconView.setImageBitmap(iconBitmap);
}
mIconView.setLayoutParams(new LayoutParams(0, 0, mSmallIconMargin, 0));
mIconView.getLayoutParams().width = mSmallIconSize;
mIconView.getLayoutParams().height = mSmallIconSize;
mIconView.setFocusable(false);
}
// Set up the message view.
mMessageMainText = message;
mMessageLayout = new InfoBarControlLayout(context);
mMessageTextView = mMessageLayout.addMainMessage(prepareMainMessageString());
}
示例15: setupPillChildView
import android.widget.ImageView; //导入方法依赖的package包/类
private LinearLayout setupPillChildView(String pillMessage, boolean isPressed, int imgResource) {
final LinearLayout lnlContainer = (LinearLayout) LayoutInflater.from(getContext())
.inflate(R.layout.pills_box_layout, this, false);
lnlContainer.setBackgroundResource(backgroundPill);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
layoutParams.setMargins(pillMarginLeft, pillMarginTop, pillMarginRight, pillMarginBottom);
lnlContainer.setLayoutParams(layoutParams);
if (isPressed) {
lnlContainer.setBackgroundResource(backgroundPillSelected);
} else {
lnlContainer.setBackgroundResource(backgroundPill);
}
//Inflating LinearLayout child for customization
LinearLayout lnlChild = (LinearLayout) lnlContainer.findViewById(R.id.lnlChild);
lnlChild.setPadding(pillPaddingLeft, pillPaddingTop, pillPaddingRight, pillPaddingBottom);
//Inflating ImageView
CirculateImageView civContact = (CirculateImageView) lnlContainer.findViewById(R.id.civContact);
if (hideContactIcon) {
civContact.setVisibility(View.VISIBLE);
} else {
civContact.setVisibility(View.GONE);
}
if (imgResource == 0) {
civContact.setImageResource(R.drawable.ic_orbismobile);
} else {
civContact.setImageResource(imgResource);
}
//Inflating TextView child for customization
TextView lblMessage = (TextView) lnlContainer.findViewById(R.id.lblMessage);
lblMessage.setText(pillMessage);
lblMessage.setTextColor(pillTextColor);
//Inflating imgClose view for customization
ImageView imgClose = (ImageView) lnlContainer.findViewById(R.id.imgClose);
imgClose.setBackgroundResource(pillCloseIcon);
if (hideCloseIcon) {
imgClose.setVisibility(View.VISIBLE);
} else {
imgClose.setVisibility(View.GONE);
}
MarginLayoutParams marginLayoutParams = (MarginLayoutParams) imgClose.getLayoutParams();
marginLayoutParams.leftMargin = closeIconMarginLeft;
imgClose.setLayoutParams(marginLayoutParams);
imgClose.setOnClickListener(this);
lnlContainer.setOnClickListener(this);
return lnlContainer;
}