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


Java ImageView.setLayoutParams方法代碼示例

本文整理匯總了Java中android.widget.ImageView.setLayoutParams方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageView.setLayoutParams方法的具體用法?Java ImageView.setLayoutParams怎麽用?Java ImageView.setLayoutParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.ImageView的用法示例。


在下文中一共展示了ImageView.setLayoutParams方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ScreenEdgesCalibrationTool

import android.widget.ImageView; //導入方法依賴的package包/類
public ScreenEdgesCalibrationTool(MainActivity _p) 
{
	p = _p;
	img = new ImageView(p);
	img.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
	img.setScaleType(ImageView.ScaleType.MATRIX);
	bmp = BitmapFactory.decodeResource( p.getResources(), R.drawable.calibrate );
	img.setImageBitmap(bmp);
	Matrix m = new Matrix();
	RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
	RectF dst = new RectF(Globals.TouchscreenCalibration[0], Globals.TouchscreenCalibration[1], 
							Globals.TouchscreenCalibration[2], Globals.TouchscreenCalibration[3]);
	m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
	img.setImageMatrix(m);
	p.getVideoLayout().addView(img);
}
 
開發者ID:NeoTerm,項目名稱:NeoTerm,代碼行數:17,代碼來源:SettingsMenuMouse.java

示例2: initialize

import android.widget.ImageView; //導入方法依賴的package包/類
private void initialize(Context context) {
    // We only want our ImageView in here. Nothing else is permitted
    removeAllViews();

    image = new ImageView(context);

    LayoutParams imageLayout = new LayoutParams(
            LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);

    image.setLayoutParams(imageLayout);

    // We want to prevent up-scaling the image, but still have it fit within
    // the layout bounds as best as possible.
    image.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    addView(image);
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:18,代碼來源:ProfilePictureView.java

示例3: 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);

}
 
開發者ID:reyanshmishra,項目名稱:Rey-MusicPlayer,代碼行數:25,代碼來源:SubGridViewAdapter.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.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

示例5: processLogic

import android.widget.ImageView; //導入方法依賴的package包/類
protected void processLogic() {
    this.mIndicatorIvList = new ArrayList();
    this.mGridViewList = new ArrayList();
    int emotionPageCount = ((MQEmotionUtil.sEmotionKeyArr.length - 1) / 27) + 1;
    LayoutParams indicatorIvLp = new LayoutParams(-2, -2);
    int margin = MQUtils.dip2px(getContext(), 5.0f);
    indicatorIvLp.setMargins(margin, margin, margin, margin);
    for (int i = 0; i < emotionPageCount; i++) {
        ImageView indicatorIv = new ImageView(getContext());
        indicatorIv.setLayoutParams(indicatorIvLp);
        indicatorIv.setImageResource(R.drawable.mq_selector_emotion_indicator);
        indicatorIv.setEnabled(false);
        this.mIndicatorIvList.add(indicatorIv);
        this.mIndicatorLl.addView(indicatorIv);
        this.mGridViewList.add(getGridView(i));
    }
    ((ImageView) this.mIndicatorIvList.get(0)).setEnabled(true);
    this.mContentVp.setAdapter(new EmotionPagerAdapter());
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:20,代碼來源:MQEmotionKeyboardLayout.java

示例6: resetImgWidthHeight

import android.widget.ImageView; //導入方法依賴的package包/類
/**
 * reset img width and height
 * @author leibing
 * @createTime 2017/2/28
 * @lastModify 2017/2/28
 * @param imageView
 * @return
 */
public ImageView resetImgWidthHeight(ImageView imageView, int originWidth, int originHeight,
                                     int targetWidth){
    // get img layout
    ViewGroup.LayoutParams para = imageView.getLayoutParams();
    // target height
    int targetHeight = (originHeight * targetWidth) / originWidth;
    // modify layout width and height
    // modify width
    para.width = targetWidth;
    // modify height
    para.height = targetHeight;
    // reset layout params
    imageView.setLayoutParams(para);

    return imageView;
}
 
開發者ID:leibing8912,項目名稱:JkImageLoader,代碼行數:25,代碼來源:JkImageLoader.java

示例7: resetIndicator

import android.widget.ImageView; //導入方法依賴的package包/類
private void resetIndicator(int currentIndex) {
    indicator.removeAllViews();
    indicatorInside.removeAllViews();
    for (int i = 0; i < count; i++) {
        ImageView imageView = new ImageView(getContext());
        imageView.setScaleType(ScaleType.CENTER_CROP);
        if (i == currentIndex) {
            imageView.setImageResource(mIndicatorSelectedResId);
        } else {
            imageView.setImageResource(mIndicatorUnselectedResId);
        }
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        lp.setMargins(mIndicatorMargin, 0, mIndicatorMargin, 0);
        imageView.setLayoutParams(lp);
        if (mBannerStyle == BannerStyle.CIRCLE_INDICATOR || mBannerStyle == BannerStyle.CIRCLE_INDICATOR_TITLE) {
            indicator.addView(imageView, lp);
        } else if (mBannerStyle == BannerStyle.CIRCLE_INDICATOR_TITLE_INSIDE) {
            indicatorInside.addView(imageView, lp);
        }
    }
}
 
開發者ID:lany192,項目名稱:BannerView,代碼行數:22,代碼來源:BannerView.java

示例8: initViews

import android.widget.ImageView; //導入方法依賴的package包/類
@Override
protected void initViews() {
    mRollPagerView = (RollPagerView) findViewById(R.id.home_rollPagerView);

    mRecyclerView = (RecyclerView) findViewById(R.id.home_recyclerView);


    ImageView imageView = new ImageView(mActivity);
    imageView.setAdjustViewBounds(true);
    imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
}
 
開發者ID:ymqq,項目名稱:CommonFramework,代碼行數:12,代碼來源:MainTabHomeFragment.java

示例9: createSelectedColorView

import android.widget.ImageView; //導入方法依賴的package包/類
private View createSelectedColorView(ImageView selectedView) {
    final ImageView fakeImageView = new CircleImageView(
        getContext(), null, R.attr.colorStyle);

    fakeImageView.setImageDrawable(selectedView.getDrawable());
    fakeImageView.setLayoutParams(SelectedParamsFactory.startColorParams(selectedView));
    return fakeImageView;
}
 
開發者ID:saulmm,項目名稱:From-design-to-Android-part1,代碼行數:9,代碼來源:OrderDialogFragment.java

示例10: PageIndicator

import android.widget.ImageView; //導入方法依賴的package包/類
public PageIndicator(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PageIndicator);
    normalIndicator = a.getResourceId(R.styleable.PageIndicator_normal_indicator,
            R.drawable.shape_ring_white);
    selectedIndicator = a.getResourceId(R.styleable.PageIndicator_selected_indicator,
            R.drawable.shape_point_white);
    leftMargin = a.getDimension(R.styleable.PageIndicator_leftMargin, dip2px(10));
    a.recycle();

    LayoutParams params = new LayoutParams
            (LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    llIndicators = new LinearLayout(context);
    llIndicators.setLayoutParams(params);
    llIndicators.setOrientation(LinearLayout.HORIZONTAL);

    indicator = new ImageView(context);
    LayoutParams params1 = new LayoutParams
            (LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    indicator.setLayoutParams(params1);
    indicator.setImageResource(selectedIndicator);//默認使用白色實心點

    this.addView(llIndicators);
    this.addView(indicator);
}
 
開發者ID:BittleDragon,項目名稱:PageIndicator,代碼行數:28,代碼來源:PageIndicator.java

示例11: onCreateView

import android.widget.ImageView; //導入方法依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    int imgRes = getArguments().getInt(IMG_RESOURCE);
    ImageView imageView = new ImageView(getContext());
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    imageView.setLayoutParams(layoutParams);
    imageView.setScaleType(ImageView.ScaleType.FIT_XY);
    imageView.setImageResource(imgRes);
    return imageView;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:PicFragment.java

示例12: initAdimgs

import android.widget.ImageView; //導入方法依賴的package包/類
/**
 * 初始化圖片
 *
 * @param urls
 */
private void initAdimgs(String[] urls) {
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    int length = urls.length + 2;
    mImageViews = new ImageView[length];
    for (int i = 0; i < length; i++) {
        ImageView imageView = new ImageView(context);
        imageView.setLayoutParams(params);
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        mImageViews[i] = imageView;
    }
    setImg(length, urls);
}
 
開發者ID:wp521,項目名稱:MyFire,代碼行數:18,代碼來源:AdViewpagerUtil.java

示例13: setIconSizeAt

import android.widget.ImageView; //導入方法依賴的package包/類
/**
 * set item ImageView size which at position
 *
 * @param position position start from 0
 * @param width    in dp
 * @param height   in dp
 */
public void setIconSizeAt(int position, float width, float height) {
    ImageView icon = getIconAt(position);
    // update size
    ViewGroup.LayoutParams layoutParams = icon.getLayoutParams();
    layoutParams.width = dp2px(getContext(), width);
    layoutParams.height = dp2px(getContext(), height);
    icon.setLayoutParams(layoutParams);

    mMenuView.updateMenuView();
}
 
開發者ID:wheat7,項目名稱:Cashew,代碼行數:18,代碼來源:BottomNavigationViewEx.java

示例14: ActionBarMenuItem

import android.widget.ImageView; //導入方法依賴的package包/類
public ActionBarMenuItem(Context context, ActionBarMenu menu, int backgroundColor) {
    super(context);
    if (backgroundColor != 0) {
        setBackgroundDrawable(Theme.createBarSelectorDrawable(backgroundColor));
    }
    parentMenu = menu;

    iconView = new ImageView(context);
    iconView.setScaleType(ImageView.ScaleType.CENTER);
    addView(iconView);
    LayoutParams layoutParams = (LayoutParams) iconView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    iconView.setLayoutParams(layoutParams);
}
 
開發者ID:chengzichen,項目名稱:KrGallery,代碼行數:16,代碼來源:ActionBarMenuItem.java

示例15: updateTabStyles

import android.widget.ImageView; //導入方法依賴的package包/類
private void updateTabStyles() {
        for (int i = 0; i < mTabCount; i++) {
            View tabView = mTabsContainer.getChildAt(i);
            tabView.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
            TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
            boolean selected = i == mCurrentTab;
            tv_tab_title.setTextColor(selected ? mTextSelectColor : mTextUnselectColor);
            tv_tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextsize);
//            tv_tab_title.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
            if (mTextAllCaps) {
                tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
            }

            if (mTextBold == TEXT_BOLD_BOTH) {
                tv_tab_title.getPaint().setFakeBoldText(true);
            } else if (mTextBold == TEXT_BOLD_NONE) {
                tv_tab_title.getPaint().setFakeBoldText(false);
            }

            ImageView iv_tab_icon = (ImageView) tabView.findViewById(R.id.iv_tab_icon);
            if (mIconVisible) {
                iv_tab_icon.setVisibility(View.VISIBLE);
//                CustomTabEntity tabEntity = mTabEntitys.get(i);
                iv_tab_icon.setColorFilter(selected ? selectIconColor : unSelectIconColor);
                LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                        mIconWidth <= 0 ? LinearLayout.LayoutParams.WRAP_CONTENT : (int) mIconWidth,
                        mIconHeight <= 0 ? LinearLayout.LayoutParams.WRAP_CONTENT : (int) mIconHeight);
                if (mIconGravity == Gravity.LEFT) {
                    lp.rightMargin = (int) mIconMargin;
                } else if (mIconGravity == Gravity.RIGHT) {
                    lp.leftMargin = (int) mIconMargin;
                } else if (mIconGravity == Gravity.BOTTOM) {
                    lp.topMargin = (int) mIconMargin;
                } else {
                    lp.bottomMargin = (int) mIconMargin;
                }

                iv_tab_icon.setLayoutParams(lp);
            } else {
                iv_tab_icon.setVisibility(View.GONE);
            }
        }
    }
 
開發者ID:Blankeer,項目名稱:MDWechat,代碼行數:44,代碼來源:CommonTabLayout.java


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