当前位置: 首页>>代码示例>>Java>>正文


Java ImageView.setAdjustViewBounds方法代码示例

本文整理汇总了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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:ProductTour2Activity.java

示例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;
}
 
开发者ID:wp521,项目名称:MyFire,代码行数:20,代码来源:MultiImageView.java

示例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);
  }
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:26,代码来源:WXEmbed.java

示例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);
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:26,代码来源:WXEmbed.java

示例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);
        }
    }
}
 
开发者ID:hsllany,项目名称:HtmlNative,代码行数:15,代码来源:BackgroundViewDelegate.java

示例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;
}
 
开发者ID:ABTSoftware,项目名称:SciChart.Android.Examples,代码行数:18,代码来源:ImageViewWidget.java

示例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();
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:11,代码来源:ViewUtil.java

示例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);
    }
}
 
开发者ID:Laaidback,项目名称:A.scribe,代码行数:24,代码来源:MainActivity.java

示例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);
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:36,代码来源:PagerSlidingTabStrip.java

示例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;
}
 
开发者ID:Crysis21,项目名称:PagerTabIndicator,代码行数:8,代码来源:PagerTabsIndicator.java

示例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;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:11,代码来源:Wallpaper.java

示例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)));
                }
            });
        }
    }
}
 
开发者ID:tringuyen1121,项目名称:Khonsu,代码行数:34,代码来源:MapNavActivity.java

示例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();
}
 
开发者ID:customerly,项目名称:Customerly-Android-SDK,代码行数:53,代码来源:IAct_FullScreenImage.java

示例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();
    }
}
 
开发者ID:xieyangxuejun,项目名称:SearchLayout,代码行数:44,代码来源:FlowSearchLayout.java

示例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);
}
 
开发者ID:li-yu,项目名称:FakeWeather,代码行数:74,代码来源:WeatherChartView.java


注:本文中的android.widget.ImageView.setAdjustViewBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。