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


Java ImageView.requestLayout方法代碼示例

本文整理匯總了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();
        }
    }
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:17,代碼來源:ImageUtil.java

示例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();
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:11,代碼來源:ViewUtil.java

示例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("");
				}
			}
		}
	}
}
 
開發者ID:gaolhjy,項目名稱:cniao5,代碼行數:52,代碼來源:PlatformPageAdapter.java

示例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);
}
 
開發者ID:commonsguy,項目名稱:cwac-crossport,代碼行數:46,代碼來源:TabLayoutLite.java

示例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;
}
 
開發者ID:pranavpandey,項目名稱:dynamic-toasts,代碼行數:68,代碼來源:DynamicHint.java

示例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;
}
 
開發者ID:pranavpandey,項目名稱:dynamic-toasts,代碼行數:68,代碼來源:DynamicToast.java

示例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);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:66,代碼來源:TabLayout.java


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