本文整理汇总了Java中android.widget.ImageView.requestLayout方法的典型用法代码示例。如果您正苦于以下问题:Java ImageView.requestLayout方法的具体用法?Java ImageView.requestLayout怎么用?Java ImageView.requestLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ImageView
的用法示例。
在下文中一共展示了ImageView.requestLayout方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
}
示例2: setImage
import android.widget.ImageView; //导入方法依赖的package包/类
/**
* Sets the image for an ImageView.
*/
public static void setImage(ImageView view, Drawable drawable) {
view.setImageDrawable(drawable);
if (drawable != null) {
view.setAdjustViewBounds(true);
}
view.requestLayout();
}
示例3: refreshPanel
import android.widget.ImageView; //导入方法依赖的package包/类
private void refreshPanel(LinearLayout[] llCells, Object[] logos) {
int cellBack = ResHelper.getBitmapRes(page.getContext(), "ssdk_oks_classic_platform_cell_back");
int disableBack = ResHelper.getBitmapRes(page.getContext(), "ssdk_oks_classic_platfrom_cell_back_nor");
for (int i = 0; i < logos.length; i++) {
ImageView ivLogo = ResHelper.forceCast(llCells[i].getChildAt(0));
TextView tvName = ResHelper.forceCast(llCells[i].getChildAt(1));
if (logos[i] == null) {
ivLogo.setVisibility(View.INVISIBLE);
tvName.setVisibility(View.INVISIBLE);
llCells[i].setBackgroundResource(disableBack);
llCells[i].setOnClickListener(null);
} else {
ivLogo.setVisibility(View.VISIBLE);
tvName.setVisibility(View.VISIBLE);
ivLogo.requestLayout();
tvName.requestLayout();
llCells[i].setBackgroundResource(cellBack);
llCells[i].setOnClickListener(this);
llCells[i].setTag(logos[i]);
if (logos[i] instanceof CustomerLogo) {
CustomerLogo logo = ResHelper.forceCast(logos[i]);
if (logo.logo != null) {
ivLogo.setImageBitmap(logo.logo);
} else {
ivLogo.setImageBitmap(null);
}
if (logo.label != null) {
tvName.setText(logo.label);
} else {
tvName.setText("");
}
} else {
Platform plat = ResHelper.forceCast(logos[i]);
String name = plat.getName().toLowerCase();
int resId = ResHelper.getBitmapRes(ivLogo.getContext(),"ssdk_oks_classic_" + name);
if (resId > 0) {
ivLogo.setImageResource(resId);
} else {
ivLogo.setImageBitmap(null);
}
resId = ResHelper.getStringRes(tvName.getContext(), "ssdk_" + name);
if (resId > 0) {
tvName.setText(resId);
} else {
tvName.setText("");
}
}
}
}
}
示例4: updateTextAndIcon
import android.widget.ImageView; //导入方法依赖的package包/类
private void updateTextAndIcon(@Nullable final TextView textView,
@Nullable final ImageView iconView) {
final Drawable icon = mTab != null ? mTab.getIcon() : null;
final CharSequence text = mTab != null ? mTab.getText() : null;
final CharSequence contentDesc = mTab != null ? mTab.getContentDescription() : null;
if (iconView != null) {
if (icon != null) {
iconView.setImageDrawable(icon);
iconView.setVisibility(VISIBLE);
setVisibility(VISIBLE);
} else {
iconView.setVisibility(GONE);
iconView.setImageDrawable(null);
}
iconView.setContentDescription(contentDesc);
}
final boolean hasText = !TextUtils.isEmpty(text);
if (textView != null) {
if (hasText) {
textView.setText(text);
textView.setVisibility(VISIBLE);
setVisibility(VISIBLE);
} else {
textView.setVisibility(GONE);
textView.setText(null);
}
textView.setContentDescription(contentDesc);
}
if (iconView != null) {
MarginLayoutParams lp = ((MarginLayoutParams) iconView.getLayoutParams());
int bottomMargin = 0;
if (hasText && iconView.getVisibility() == VISIBLE) {
// If we're showing both text and icon, add some margin bottom to the icon
bottomMargin = dpToPx(DEFAULT_GAP_TEXT_ICON);
}
if (bottomMargin != lp.bottomMargin) {
lp.bottomMargin = bottomMargin;
iconView.requestLayout();
}
}
TooltipCompat.setTooltipText(this, hasText ? null : contentDesc);
}
示例5: make
import android.widget.ImageView; //导入方法依赖的package包/类
/**
* Make a themed toast with text, icon, toastBackground and the tint color.
*
* @param context The context to use. Usually your {@link android.app.Application}
* or {@link android.app.Activity} object.
* @param text The text to show. Can be formatted text.
* @param icon The toast icon to show.
* @param tintColor The toast tint color based on the toastBackground. It will
* automatically check for the contrast to provide best
* visibility.
* @param backgroundColor The toast toastBackground color.
* @param duration How long to display the message. Either
* {@link Toast#LENGTH_SHORT} or {@link Toast#LENGTH_LONG}.
*
* @return Toast with the supplied parameters. Use {@link Toast#show()}
* to display the toast.
*/
public static @NonNull Toast make(@NonNull Context context, @Nullable CharSequence text,
@Nullable Drawable icon, @ColorInt int tintColor,
@ColorInt int backgroundColor, int duration) {
final Toast toast = new Toast(context);
final View toastLayout = LayoutInflater.from(context).inflate(
R.layout.adt_layout_hint, new LinearLayout(context), false);
final ImageView toastIcon = toastLayout.findViewById(R.id.adt_hint_icon);
final TextView toastText = toastLayout.findViewById(R.id.adt_hint_text);
tintColor = DynamicColorUtils.getContrastColor(tintColor, backgroundColor);
if (icon != null && !disableIcon) {
if (iconSize != ADT_DEFAULT_ICON_SIZE) {
toastIcon.getLayoutParams().width = iconSize;
toastIcon.getLayoutParams().height = iconSize;
toastIcon.requestLayout();
}
toastIcon.setColorFilter(tintColor);
toastIcon.setImageDrawable(icon);
} else {
toastIcon.setVisibility(View.GONE);
}
if (textTypeface != null) {
toastText.setTypeface(textTypeface);
}
if (textSize != ADT_DEFAULT_TEXT_SIZE) {
toastText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
}
toastText.setTextColor(tintColor);
toastText.setText(text);
if (toastBackground != null) {
DynamicDrawableUtils.setBackground(toastLayout,
DynamicDrawableUtils.colorizeDrawable(toastBackground,
backgroundColor, PorterDuff.Mode.MULTIPLY));
} else {
DynamicDrawableUtils.setBackground(toastLayout,
DynamicDrawableUtils.colorizeDrawable(
ContextCompat.getDrawable(context, R.drawable.adt_hint_frame),
backgroundColor, PorterDuff.Mode.MULTIPLY));
}
toast.setDuration(duration);
toast.setView(toastLayout);
return toast;
}
示例6: make
import android.widget.ImageView; //导入方法依赖的package包/类
/**
* Make a themed toast with text, icon, toastBackground and the tint color.
*
* @param context The context to use. Usually your {@link android.app.Application}
* or {@link android.app.Activity} object.
* @param text The text to show. Can be formatted text.
* @param icon The toast icon to show.
* @param tintColor The toast tint color based on the toastBackground. It will
* automatically check for the contrast to provide best
* visibility.
* @param backgroundColor The toast toastBackground color.
* @param duration How long to display the message. Either
* {@link Toast#LENGTH_SHORT} or {@link Toast#LENGTH_LONG}.
*
* @return Toast with the supplied parameters. Use {@link Toast#show()}
* to display the toast.
*/
public static @NonNull Toast make(@NonNull Context context, @Nullable CharSequence text,
@Nullable Drawable icon, @ColorInt int tintColor,
@ColorInt int backgroundColor, int duration) {
final Toast toast = new Toast(context);
final View toastLayout = LayoutInflater.from(context).inflate(
R.layout.adt_layout_toast, new LinearLayout(context), false);
final ImageView toastIcon = toastLayout.findViewById(R.id.adt_toast_icon);
final TextView toastText = toastLayout.findViewById(R.id.adt_toast_text);
tintColor = DynamicColorUtils.getContrastColor(tintColor, backgroundColor);
if (icon != null && !disableIcon) {
if (iconSize != ADT_DEFAULT_ICON_SIZE) {
toastIcon.getLayoutParams().width = iconSize;
toastIcon.getLayoutParams().height = iconSize;
toastIcon.requestLayout();
}
toastIcon.setColorFilter(tintColor);
toastIcon.setImageDrawable(icon);
} else {
toastIcon.setVisibility(View.GONE);
}
if (textTypeface != null) {
toastText.setTypeface(textTypeface);
}
if (textSize != ADT_DEFAULT_TEXT_SIZE) {
toastText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
}
toastText.setTextColor(tintColor);
toastText.setText(text);
if (toastBackground != null) {
DynamicDrawableUtils.setBackground(toastLayout,
DynamicDrawableUtils.colorizeDrawable(toastBackground,
backgroundColor, PorterDuff.Mode.MULTIPLY));
} else {
DynamicDrawableUtils.setBackground(toastLayout,
DynamicDrawableUtils.colorizeDrawable(
ContextCompat.getDrawable(context, R.drawable.adt_toast_frame),
backgroundColor, PorterDuff.Mode.MULTIPLY));
}
toast.setDuration(duration);
toast.setView(toastLayout);
return toast;
}
示例7: updateTextAndIcon
import android.widget.ImageView; //导入方法依赖的package包/类
private void updateTextAndIcon(@Nullable TextView textView, @Nullable ImageView iconView) {
Drawable icon;
CharSequence text;
CharSequence contentDesc;
boolean hasText;
if (this.mTab != null) {
icon = this.mTab.getIcon();
} else {
icon = null;
}
if (this.mTab != null) {
text = this.mTab.getText();
} else {
text = null;
}
if (this.mTab != null) {
contentDesc = this.mTab.getContentDescription();
} else {
contentDesc = null;
}
if (iconView != null) {
if (icon != null) {
iconView.setImageDrawable(icon);
iconView.setVisibility(0);
setVisibility(0);
} else {
iconView.setVisibility(8);
iconView.setImageDrawable(null);
}
iconView.setContentDescription(contentDesc);
}
if (TextUtils.isEmpty(text)) {
hasText = false;
} else {
hasText = true;
}
if (textView != null) {
if (hasText) {
textView.setText(text);
textView.setVisibility(0);
setVisibility(0);
} else {
textView.setVisibility(8);
textView.setText(null);
}
textView.setContentDescription(contentDesc);
}
if (iconView != null) {
MarginLayoutParams lp = (MarginLayoutParams) iconView.getLayoutParams();
int bottomMargin = 0;
if (hasText && iconView.getVisibility() == 0) {
bottomMargin = TabLayout.this.dpToPx(8);
}
if (bottomMargin != lp.bottomMargin) {
lp.bottomMargin = bottomMargin;
iconView.requestLayout();
}
}
if (hasText || TextUtils.isEmpty(contentDesc)) {
setOnLongClickListener(null);
setLongClickable(false);
return;
}
setOnLongClickListener(this);
}