本文整理匯總了Java中android.widget.ImageView.setAdjustViewBounds方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageView.setAdjustViewBounds方法的具體用法?Java ImageView.setAdjustViewBounds怎麽用?Java ImageView.setAdjustViewBounds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.ImageView
的用法示例。
在下文中一共展示了ImageView.setAdjustViewBounds方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildCircles
import android.widget.ImageView; //導入方法依賴的package包/類
private void buildCircles(){
circles = LinearLayout.class.cast(findViewById(R.id.circles));
float scale = getResources().getDisplayMetrics().density;
int padding = (int) (5 * scale + 0.5f);
for(int i = 0 ; i < NUM_PAGES - 1 ; i++){
ImageView circle = new ImageView(this);
circle.setImageResource(R.drawable.ic_swipe_indicator_white_18dp);
circle.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
circle.setAdjustViewBounds(true);
circle.setPadding(padding, 0, padding, 0);
circles.addView(circle);
}
setIndicator(0);
}
示例2: createImageView
import android.widget.ImageView; //導入方法依賴的package包/類
private ImageView createImageView(int position, final boolean isMultiImage) {
String url = imagesList.get(position);
ImageView imageView = new ColorFilterImageView(getContext());
if(isMultiImage){
imageView.setScaleType(ScaleType.CENTER_CROP);
imageView.setLayoutParams(position % MAX_PER_ROW_COUNT == 0 ?moreParaColumnFirst : morePara);
}else {
imageView.setAdjustViewBounds(true);
imageView.setScaleType(ScaleType.CENTER_CROP);
imageView.setMaxHeight(pxOneMaxWandH);
imageView.setLayoutParams(onePicPara);
}
imageView.setTag(R.string.zone_img_position,position);
imageView.setId(url.hashCode());
imageView.setOnClickListener(mImageViewOnClickListener);
ImageLoaderUtils.display(getContext(), imageView, ImageUtil.getImageUrl(url));
return imageView;
}
示例3: onException
import android.widget.ImageView; //導入方法依賴的package包/類
@Override
public void onException(NestedContainer container, String errCode, String msg) {
if (TextUtils.equals(errCode, WXRenderErrorCode.WX_NETWORK_ERROR) && container instanceof WXEmbed) {
final WXEmbed comp = ((WXEmbed)container);
final ImageView imageView = new ImageView(comp.getContext());
imageView.setImageResource(R.drawable.error);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ERROR_IMG_WIDTH, ERROR_IMG_HEIGHT);
layoutParams.gravity = Gravity.CENTER;
imageView.setLayoutParams(layoutParams);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setAdjustViewBounds(true);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
imageView.setOnClickListener(null);
imageView.setEnabled(false);
comp.loadContent();
}
});
FrameLayout hostView = comp.getHostView();
hostView.removeAllViews();
hostView.addView(imageView);
WXLogUtils.e("WXEmbed", "NetWork failure :" + errCode + ",\n error message :" + msg);
}
}
示例4: onException
import android.widget.ImageView; //導入方法依賴的package包/類
@Override
public void onException(NestedContainer container, String errCode, String msg) {
if (TextUtils.equals(errCode, WXRenderErrorCode.WX_NETWORK_ERROR) && container instanceof WXEmbed) {
final WXEmbed comp = ((WXEmbed)container);
final ImageView imageView = new ImageView(comp.getContext());
imageView.setImageResource(R.drawable.error);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ERROR_IMG_WIDTH, ERROR_IMG_HEIGHT);
layoutParams.gravity = Gravity.CENTER;
imageView.setLayoutParams(layoutParams);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setAdjustViewBounds(true);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
imageView.setOnClickListener(null);
imageView.setEnabled(false);
comp.loadInstance();
}
});
FrameLayout hostView = comp.getHostView();
hostView.removeAllViews();
hostView.addView(imageView);
WXLogUtils.e("WXEmbed", "NetWork failure :" + errCode + ",\n error message :" + msg);
}
}
示例5: setBitmap
import android.widget.ImageView; //導入方法依賴的package包/類
public void setBitmap(Bitmap bitmap) {
if (mView instanceof ImageView && mIsSrc) {
ImageView imageView = (ImageView) mView;
imageView.setAdjustViewBounds(true);
if (mTransformMatrix != null) {
imageView.setImageMatrix(mTransformMatrix);
}
imageView.setImageBitmap(bitmap);
} else {
if (mView instanceof IBackgroundView) {
((IBackgroundManager) mView).setHtmlBackground(bitmap, mBackground);
}
}
}
示例6: createView
import android.widget.ImageView; //導入方法依賴的package包/類
@Override
public View createView(Context context) {
LayoutInflater inflater = LayoutInflater.from(context);
RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.example_toolbar_item, null, false);
layout.setOnClickListener(onClickListener);
ImageView imageView = new ImageView(context);
imageView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
imageView.setAdjustViewBounds(true);
imageView.setImageResource(id);
layout.addView(imageView);
return layout;
}
示例7: 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();
}
示例8: initializeColorBar
import android.widget.ImageView; //導入方法依賴的package包/類
private void initializeColorBar() {
drawerLayout.setScrimColor(ContextCompat.getColor(this, R.color.scrimColor));
for (NoteColor noteColor : NoteColor.values()) {
ImageView view = new ImageView(this);
Drawable circle;
if (noteColor == NoteColor.NO_COLOR) {
circle = ResourcesCompat.getDrawable(getResources(),
R.drawable.ic_remove_filter, null);
} else {
circle = ResourcesCompat.getDrawable(getResources(),
R.drawable.color_circle, null);
circle.setColorFilter(Color.parseColor(noteColor.toHexString()),
PorterDuff.Mode.SRC_IN);
}
view.setImageDrawable(circle);
view.setLayoutParams(getColorBarItemParams());
view.setTag(noteColor);
view.setOnClickListener(getOnClickListener());
view.setAdjustViewBounds(true);
view.setScaleType(ImageView.ScaleType.FIT_CENTER);
colorBar.addView(view);
}
}
示例9: 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);
}
示例10: createImageView
import android.widget.ImageView; //導入方法依賴的package包/類
private View createImageView() {
ImageView imageView = new ImageView(getContext());
imageView.setPadding(tabPadding, tabPadding, tabPadding, tabPadding);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setAdjustViewBounds(true);
return imageView;
}
示例11: getView
import android.widget.ImageView; //導入方法依賴的package包/類
public View getView(final int position, View convertView, ViewGroup parent) {
ImageView i = new ImageView(mContext);
i.setImageResource(THUMB_IDS[position]);
i.setAdjustViewBounds(true);
i.setLayoutParams(new Gallery.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
i.setBackgroundResource(android.R.drawable.picture_frame);
return i;
}
示例12: displayPossibleDestination
import android.widget.ImageView; //導入方法依賴的package包/類
private void displayPossibleDestination() {
List<Location> destinations = dbHelper.getAllLocation();
RelativeLayout la = (RelativeLayout)findViewById(R.id.map_layout_child);
for (final Location loc: destinations) {
if (loc.getLocationId().intValue() != startLoc.getLocationId().intValue()) {
final ImageView desPin = new ImageView(this);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(getResources().getDimensionPixelSize(R.dimen.pin_size), ViewGroup.LayoutParams.WRAP_CONTENT);
desPin.setImageResource(R.drawable.ic_app_icon);
desPin.setScaleType(ImageView.ScaleType.CENTER_CROP);
desPin.setAdjustViewBounds(true);
// when user choose a destination, display a path how to get to it
desPin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
currentRoute = dbHelper.getRoute(startLoc, loc);
List<Path> paths = currentRoute.getPaths();
drawPaths(paths);
currentPathIndex = 0;
currentPath = currentRoute.getPaths().get(currentPathIndex);
}
});
la.addView(desPin, params);
desPin.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
desPin.setX((float) Math.abs(desPin.getWidth() / 2 - (loc.getLocationX() * mapWidth)));
desPin.setY((float) Math.abs(desPin.getHeight() - (loc.getLocationY() * mapHeight)));
}
});
}
}
}
示例13: onCreate
import android.widget.ImageView; //導入方法依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(this.getIntent() != null) {
this._SourceUrl = this.getIntent().getStringExtra(EXTRA_IMAGE_SOURCE);
if(this._SourceUrl != null) {
ImageView _ImageView = new TouchImageView(this);
_ImageView.setBackgroundColor(Color.WHITE);
_ImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
_ImageView.setAdjustViewBounds(true);
try {
Customerly.get()._RemoteImageHandler.request(new IU_RemoteImageHandler.Request()
.fitCenter()
.load(this._SourceUrl)
.into(this, _ImageView)
.placeholder(R.drawable.io_customerly__pic_placeholder_fullscreen));
super.setContentView(_ImageView);
final ActionBar actionBar = this.getSupportActionBar();
if (actionBar != null) {
String title;
if(Customerly.get().__PING__LAST_widget_color != 0) {
actionBar.setBackgroundDrawable(new ColorDrawable(Customerly.get().__PING__LAST_widget_color));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
this.getWindow().setStatusBarColor(IU_Utils.alterColor(Customerly.get().__PING__LAST_widget_color, 0.8f));
}
if (IU_Utils.getContrastColor(Customerly.get().__PING__LAST_widget_color) == Color.BLACK) {
actionBar.setHomeAsUpIndicator(R.drawable.io_customerly__ic_arrow_back_black_24dp);
title = String.format("<font color='#000000'>%1$s</font>", actionBar.getTitle());
} else {
actionBar.setHomeAsUpIndicator(R.drawable.io_customerly__ic_arrow_back_white_24dp);
title = String.format("<font color='#ffffff'>%1$s</font>", actionBar.getTitle());
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
actionBar.setTitle(Html.fromHtml(title, 0));
} else {
//noinspection deprecation
actionBar.setTitle(Html.fromHtml(title));
}
}
actionBar.setDisplayHomeAsUpEnabled(true);
}
return;
} catch (Exception glideException) {
IEr_CustomerlyErrorHandler.sendError(IEr_CustomerlyErrorHandler.ERROR_CODE__GLIDE_ERROR, "Error during Glide loading in FullScreenImage_Activity", glideException);
}
}
}
this.finish();
}
示例14: initSearchView
import android.widget.ImageView; //導入方法依賴的package包/類
private void initSearchView() {
SearchView searchView = mBinding.svSearch;
//設置搜索框左邊距
LinearLayout editFrame = (LinearLayout) findViewById(R.id.search_edit_frame);
LinearLayout.LayoutParams editP = (LayoutParams) editFrame.getLayoutParams();
editP.leftMargin = 0;
editP.rightMargin = 0;
ImageView imageView = (ImageView) findViewById(R.id.search_mag_icon);
imageView.setAdjustViewBounds(true);
imageView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
LinearLayout.LayoutParams lp3 = (LayoutParams) imageView.getLayoutParams();
lp3.gravity = Gravity.CENTER_VERTICAL;
lp3.leftMargin = (int) (DensityUtil.dip2px(8f) * DensityUtil.getBaseScale(getContext()));
lp3.rightMargin = (int) (DensityUtil.dip2px(-2f) * DensityUtil.getBaseScale(getContext()));
View view = searchView.findViewById(R.id.search_plate);
view.setBackgroundColor(getResources().getColor(R.color.colorTransparent));
EditText editText = (EditText) searchView.findViewById(R.id.search_src_text);
editText.setBackgroundColor(Color.TRANSPARENT);
editText.setTextSize(11.5f);
editText.setTextColor(getResources().getColor(R.color.colorText));
editText.setHintTextColor(getResources().getColor(R.color.colorHint));
try {
Field fCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
fCursorDrawableRes.setAccessible(true);
int mCursorDrawableRes = fCursorDrawableRes.getInt(editText);
Field fEditor = TextView.class.getDeclaredField("mEditor");
fEditor.setAccessible(true);
Object editor = fEditor.get(editText);
Class<?> clazz = editor.getClass();
Field fCursorDrawable = clazz.getDeclaredField("mCursorDrawable");
fCursorDrawable.setAccessible(true);
if (mCursorDrawableRes <= 0) return;
Drawable cursorDrawable = ContextCompat.getDrawable(searchView.getContext(), mCursorDrawableRes);
if (cursorDrawable == null) return;
Drawable tintDrawable = DrawableCompat.wrap(cursorDrawable);
DrawableCompat.setTintList(tintDrawable, ColorStateList.valueOf(ContextCompat.getColor(getContext(), R.color.bg_search)));
Drawable[] drawables = new Drawable[]{tintDrawable, tintDrawable};
fCursorDrawable.set(editor, drawables);
} catch (Throwable t) {
t.printStackTrace();
}
}
示例15: letItGo
import android.widget.ImageView; //導入方法依賴的package包/類
private void letItGo() {
removeAllViews();
final LinearLayout dateTitleView = new LinearLayout(getContext());
dateTitleView.setLayoutParams(rowParams);
dateTitleView.setOrientation(HORIZONTAL);
dateTitleView.setLayoutTransition(transition);
dateTitleView.removeAllViews();
final LinearLayout iconView = new LinearLayout(getContext());
iconView.setLayoutParams(rowParams);
iconView.setOrientation(HORIZONTAL);
iconView.setLayoutTransition(transition);
iconView.removeAllViews();
final LinearLayout weatherStrView = new LinearLayout(getContext());
weatherStrView.setLayoutParams(rowParams);
weatherStrView.setOrientation(HORIZONTAL);
weatherStrView.setLayoutTransition(transition);
weatherStrView.removeAllViews();
List<Integer> minTemp = new ArrayList<>();
List<Integer> maxTemp = new ArrayList<>();
for (int i = 0; i < dailyForecastList.size(); i++) {
final TextView tvDate = new TextView(getContext());
tvDate.setGravity(Gravity.CENTER);
tvDate.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10);
tvDate.setTextColor(getResources().getColor(R.color.colorTextDark));
tvDate.setVisibility(INVISIBLE);
final TextView tvWeather = new TextView((getContext()));
tvWeather.setGravity(Gravity.CENTER);
tvWeather.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10);
tvWeather.setTextColor(getResources().getColor(R.color.colorTextDark));
tvWeather.setVisibility(INVISIBLE);
final ImageView ivIcon = new ImageView(getContext());
ivIcon.setAdjustViewBounds(true);
ivIcon.setScaleType(ImageView.ScaleType.FIT_CENTER);
int padding = SizeUtils.dp2px(getContext(), 10);
int width = SizeUtils.getScreenWidth(getContext()) / dailyForecastList.size();
LayoutParams ivParam = new LayoutParams(width, width);
ivParam.weight = 1;
ivIcon.setLayoutParams(ivParam);
ivIcon.setPadding(padding, padding, padding, padding);
ivIcon.setVisibility(INVISIBLE);
tvDate.setText(dailyForecastList.get(i).getDate());
tvWeather.setText(dailyForecastList.get(i).getTxt());
WeatherUtil.getInstance().getWeatherDict(dailyForecastList.get(i).getCode()).observeOn(AndroidSchedulers.mainThread()).subscribe(new SimpleSubscriber<WeatherBean>() {
@Override
public void onNext(WeatherBean weatherBean) {
Glide.with(getContext()).load(weatherBean.getIcon()).diskCacheStrategy(DiskCacheStrategy.ALL).into(ivIcon);
}
});
minTemp.add(Integer.valueOf(dailyForecastList.get(i).getMinTemp()));
maxTemp.add(Integer.valueOf(dailyForecastList.get(i).getMaxTemp()));
weatherStrView.addView(tvWeather, cellParams);
dateTitleView.addView(tvDate, cellParams);
iconView.addView(ivIcon);
this.postDelayed(new Runnable() {
@Override
public void run() {
tvDate.setVisibility(VISIBLE);
tvWeather.setVisibility(VISIBLE);
ivIcon.setVisibility(VISIBLE);
}
}, 200 * i);
}
addView(dateTitleView);
addView(iconView);
addView(weatherStrView);
final ChartView chartView = new ChartView(getContext());
chartView.setData(minTemp, maxTemp);
chartView.setPadding(0, SizeUtils.dp2px(getContext(), 16), 0, SizeUtils.dp2px(getContext(), 16));
addView(chartView, chartParams);
}