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


Java AppCompatImageView.setLayoutParams方法代码示例

本文整理汇总了Java中android.support.v7.widget.AppCompatImageView.setLayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java AppCompatImageView.setLayoutParams方法的具体用法?Java AppCompatImageView.setLayoutParams怎么用?Java AppCompatImageView.setLayoutParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.widget.AppCompatImageView的用法示例。


在下文中一共展示了AppCompatImageView.setLayoutParams方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addIconNormal

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
private void addIconNormal() {
    View view = LayoutInflater.from(getContext()).inflate(R.layout.indicator_single_icon, holder, false);
    view.setLayoutParams(getItemParams());

    AppCompatImageView imageView = (AppCompatImageView) view.findViewById(R.id.ic_single);
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) imageView.getLayoutParams();
    params.setMargins(indicatorAttr.eai_ic_margin, indicatorAttr.eai_ic_margin, indicatorAttr.eai_ic_margin, indicatorAttr.eai_ic_margin);
    imageView.setLayoutParams(params);
    if (iconNormalResId != 0)
        imageView.setImageResource(iconNormalResId);
    else
        imageView.setImageDrawable(indicatorAttr.eai_ic_src);
    imageView.invalidate();
    holder.addView(view);
    holder.invalidate();
}
 
开发者ID:ahmet12,项目名称:easlider,代码行数:17,代码来源:EAIndicator.java

示例2: onCreateViewHolder

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    AppCompatImageView img = new AppCompatImageView(parent.getContext());
    RecyclerView.LayoutParams params = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    img.setLayoutParams(params);
    img.setId(R.id.rvb_banner_image_view_id);
    img.setScaleType(AppCompatImageView.ScaleType.CENTER_CROP);
    img.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (onRvBannerClickListener != null) {
                onRvBannerClickListener.onClick(currentIndex % mData.size());
            }
        }
    });
    return new RecyclerView.ViewHolder(img) {
    };
}
 
开发者ID:loonggg,项目名称:RecyclerViewBanner,代码行数:20,代码来源:RecyclerViewBanner.java

示例3: init

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    mImageHeart = new AppCompatImageView(context);
    TypedArray a = context.getTheme().obtainStyledAttributes(
            attrs,
            R.styleable.InstaLikeView,
            defStyleAttr, 0);

    int likeColor = a.getColor(R.styleable.InstaLikeView_likeColor, ContextCompat.getColor(context, R.color.heartColor));
    int likeSrc = a.getResourceId(R.styleable.InstaLikeView_likeSrc, R.drawable.img_heart);
    int likeSize = a.getDimensionPixelSize(R.styleable.InstaLikeView_likeSize, getResources().getDimensionPixelSize(R.dimen.likeSize));


    LayoutParams heartParams = new LayoutParams(likeSize, likeSize);
    heartParams.addRule(CENTER_IN_PARENT, TRUE);

    mImageHeart.setLayoutParams(heartParams);
    mImageHeart.setVisibility(GONE);
    mImageHeart.setImageResource(likeSrc);
    mImageHeart.setColorFilter(likeColor);
    addView(mImageHeart);
}
 
开发者ID:Kshitij-Jain,项目名称:InstaLikeView,代码行数:22,代码来源:InstaLikeView.java

示例4: initViews

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
private void initViews() {
    setLayoutParams(new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1));
    setOrientation(HORIZONTAL);
    setGravity(Gravity.CENTER);

    imageView = new AppCompatImageView(getContext());
    imageView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) {{
        gravity = Gravity.CENTER;
    }});
    setDrawableAttrs();
    addView(imageView);

    textView = new AppCompatTextView(getContext());
    textView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) {{
        gravity = Gravity.CENTER;
    }});
    setTextAttrs();
    addView(textView);
}
 
开发者ID:ceryle,项目名称:RadioRealButton,代码行数:20,代码来源:RadioRealButton.java

示例5: initPreContainer

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
private void initPreContainer(){
    preContainer=new LinearLayout(getContext());
    preContainer.setOrientation(LinearLayout.HORIZONTAL);
    LayoutParams lp=new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.gravity=Gravity.CENTER_VERTICAL;
    preContainer.setLayoutParams(lp);
    preContainer.setOnClickListener(this);
    AppCompatImageView tmpImageView=new AppCompatImageView(getContext());
    tmpImageView.setBackgroundResource(R.mipmap.ic_image_black_24dp);
    AppCompatTextView tmpTextView=new AppCompatTextView(getContext());
    LinearLayout.LayoutParams lp1=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp1.gravity=Gravity.CENTER_VERTICAL;
    tmpImageView.setLayoutParams(lp1);
    tmpTextView.setLayoutParams(lp1);
    tmpTextView.setText(getContext().getString(R.string.select_photo));
    preContainer.addView(tmpImageView);
    preContainer.addView(tmpTextView);
    this.addView(preContainer);
}
 
开发者ID:tianyuan168326,项目名称:nono-android,代码行数:20,代码来源:PhotoLayout.java

示例6: initImgContainer

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
private void initImgContainer(){
    LinearLayout linearLayout=new LinearLayout(getContext());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    imageView=new AppCompatImageView(getContext());
    LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    imageView.setLayoutParams(lp);
    linearLayout.addView(imageView);
    imageView.setOnClickListener(this);
    editText=new AppCompatEditText(getContext());
    linearLayout.addView(editText);
    editText.setVisibility(GONE);
    editText.setTextAppearance(getContext(),R.style.NoteTextAppearance);
    editText.setGravity(Gravity.CENTER);
    editText.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if(keyCode==KeyEvent.KEYCODE_DEL&&editText.getText().toString().isEmpty()){
                editText.setVisibility(GONE);
            }
            return false;
        }
    });
    this.addView(linearLayout);
}
 
开发者ID:tianyuan168326,项目名称:nono-android,代码行数:26,代码来源:PhotoLayout.java

示例7: initView

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
private void initView(Context context){
    this.fingerprintManager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
    this.cipherHelper = null;
    this.handler = new Handler();
    this.fingerprintCallback = null;
    this.fingerprintSecureCallback = null;
    this.counterCallback = null;
    this.cryptoObject = null;
    this.tryCounter = 0;
    this.delayAfterError = DEFAULT_DELAY_AFTER_ERROR;

    int fingerprintSize = (int) (size*SCALE);
    int circleSize = size;

    fingerprintImageView = new AppCompatImageView(context);
    fingerprintImageView.setLayoutParams(new RelativeLayout.LayoutParams(fingerprintSize, fingerprintSize));
    fingerprintImageView.setBackgroundResource(R.drawable.fingerprint);
    ((RelativeLayout.LayoutParams)fingerprintImageView.getLayoutParams()).addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);

    circleView = new View(context);
    circleView.setLayoutParams(new RelativeLayout.LayoutParams(circleSize, circleSize));
    circleView.setBackgroundResource(R.drawable.circle);
    ((RelativeLayout.LayoutParams)circleView.getLayoutParams()).addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);

    setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT));
    addView(circleView);
    addView(fingerprintImageView);

    setStatus(R.drawable.fingerprint, fingerprintScanning, circleScanning);
}
 
开发者ID:OmarAflak,项目名称:Fingerprint,代码行数:31,代码来源:Fingerprint.java

示例8: addIconCurrent

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
private void addIconCurrent() {
    currentIconView = (RelativeLayout) LayoutInflater.from(getContext()).inflate(R.layout.indicator_single_icon, this, false);
    currentIconView.setLayoutParams(getItemParams());

    AppCompatImageView imageView = (AppCompatImageView) currentIconView.findViewById(R.id.ic_single);
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) imageView.getLayoutParams();
    params.setMargins(indicatorAttr.eai_ic_current_margin, indicatorAttr.eai_ic_current_margin, indicatorAttr.eai_ic_current_margin, indicatorAttr.eai_ic_current_margin);

    imageView.setLayoutParams(params);
    if (iconSelectedResId != 0)
        imageView.setImageResource(iconSelectedResId);
    else
        imageView.setImageDrawable(indicatorAttr.eai_ic_current_src);
    imageView.invalidate();

    tempView = (RelativeLayout) LayoutInflater.from(getContext()).inflate(R.layout.indicator_single_icon, this, false);
    tempView.setLayoutParams(getItemParams());

    AppCompatImageView imageView2 = (AppCompatImageView) tempView.findViewById(R.id.ic_single);
    imageView2.setLayoutParams(params);
    if (iconSelectedResId != 0)
        imageView2.setImageResource(iconSelectedResId);
    else
        imageView2.setImageDrawable(indicatorAttr.eai_ic_current_src);
    imageView2.invalidate();

    addView(currentIconView);
    addView(tempView);

    invalidate();
}
 
开发者ID:ahmet12,项目名称:easlider,代码行数:32,代码来源:EAIndicator.java

示例9: onBindViewHolder

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
    if (holder instanceof PhotoLayoutHolder) {
        Photo photo = (Photo) objects.get(position);
        AppCompatImageView photoImageView = ((PhotoLayoutHolder) holder).photoImageView;
        photoImageView.setLayoutParams(new FrameLayout.LayoutParams(imageSize, imageSize));
        Picasso.with(context).load(photo.drawableResId).into(photoImageView);
    }
}
 
开发者ID:nissiy,项目名称:GridLayoutSample,代码行数:10,代码来源:PhotoGridAdapter.java

示例10: setHeight

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
private void setHeight(AppCompatImageView imageView,float height){
    RelativeLayout.LayoutParams layoutParms = (RelativeLayout.LayoutParams)imageView.getLayoutParams();
    layoutParms.height = (int) height;
    imageView.setLayoutParams(layoutParms);
}
 
开发者ID:RuanXiaoHui,项目名称:PlainFly,代码行数:6,代码来源:SkyLayout.java

示例11: addArcAnimation

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
/**
 * Add arc above/below the circular target overlay.
 */
private void addArcAnimation(final Activity activity) {
    AppCompatImageView mImageView = new AppCompatImageView(activity);
    mImageView.setImageResource(R.drawable.ic_spotlight_arc);
    LayoutParams params = new LayoutParams(2 * (circleShape.getRadius() + extraPaddingForArc),
            2 * (circleShape.getRadius() + extraPaddingForArc));


    if (targetView.getPoint().y > getHeight() / 2) {//bottom
        if (targetView.getPoint().x > getWidth() / 2) {//Right
            params.rightMargin = getWidth() - targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc;
            params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc;
            params.gravity = Gravity.RIGHT | Gravity.BOTTOM;
        } else {
            params.leftMargin = targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc;
            params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc;
            params.gravity = Gravity.LEFT | Gravity.BOTTOM;
        }
    } else {//up
        mImageView.setRotation(180); //Reverse the view
        if (targetView.getPoint().x > getWidth() / 2) {//Right
            params.rightMargin = getWidth() - targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc;
            params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc;
            params.gravity = Gravity.RIGHT | Gravity.BOTTOM;
        } else {
            params.leftMargin = targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc;
            params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc;
            params.gravity = Gravity.LEFT | Gravity.BOTTOM;
        }

    }
    mImageView.postInvalidate();
    mImageView.setLayoutParams(params);
    addView(mImageView);

    PorterDuffColorFilter porterDuffColorFilter = new PorterDuffColorFilter(lineAndArcColor,
            PorterDuff.Mode.SRC_ATOP);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        AnimatedVectorDrawable avd = (AnimatedVectorDrawable)
                ContextCompat.getDrawable(activity, R.drawable.avd_spotlight_arc);
        avd.setColorFilter(porterDuffColorFilter);
        mImageView.setImageDrawable(avd);
        avd.start();
    } else {
        AnimatedVectorDrawableCompat avdc =
                AnimatedVectorDrawableCompat.create(activity, R.drawable.avd_spotlight_arc);
        avdc.setColorFilter(porterDuffColorFilter);
        mImageView.setImageDrawable(avdc);
        avdc.start();

    }

    new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
        @Override
        public void run() {
            addPathAnimation(activity);
        }
    }, 400);
}
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:62,代码来源:SpotlightView.java

示例12: initBackground

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
private void initBackground(AttributeSet attrs, int defStyle) {
    mPlanetView = new AppCompatImageView(getContext());

    mStarView = new AppCompatImageView(getContext());
    final LinearLayout.LayoutParams mParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    mStarView.setLayoutParams(mParams);
    addView(mStarView);

    mStarView.setAlpha(0f);

    mStarDrawable = new ParticlesDrawable();
    mStarDrawable.setStepMultiplier(0.5f);
    //mStarDrawable.setFrameDelay(2000);
    mStarDrawable.setLineVisibility(false);

    if(Build.VERSION.SDK_INT >= 16) {
        mStarView.setBackground(mStarDrawable);
    } else {
        mStarView.setBackgroundDrawable(mStarDrawable);
    }

    mStarView.setImageResource(R.drawable.alpha_gradient);

    TypedArray mArray;

    if(defStyle == 0) {
        mArray = getContext().obtainStyledAttributes(attrs, R.styleable.SkyTimeBackgroundView);
    } else {
        mArray = getContext().obtainStyledAttributes(attrs, R.styleable.SkyTimeBackgroundView, defStyle, 0);
    }

    isAutoStart = mArray.getBoolean(R.styleable.SkyTimeBackgroundView_autoStart, false);
    isPlanetAnimationOn = mArray.getBoolean(R.styleable.SkyTimeBackgroundView_planetAnimation, false);
    isPlanetVisible = mArray.getBoolean(R.styleable.SkyTimeBackgroundView_planetVisible, true);
    isStarVisible = mArray.getBoolean(R.styleable.SkyTimeBackgroundView_starVisible, true);
    if(mArray.getString(R.styleable.SkyTimeBackgroundView_starLineVisible) != null) {
        if(mArray.getString(R.styleable.SkyTimeBackgroundView_starLineVisible).equals("auto")) {
            isStarLineVisible = mArray.getBoolean(R.styleable.SkyTimeBackgroundView_starLineVisible, true);
            isStarLineVisibleAuto = true;
        }
    } else{
        isStarLineVisible = mArray.getBoolean(R.styleable.SkyTimeBackgroundView_starLineVisible, true);
        isStarLineVisibleAuto = false;
    }

    String s = mArray.getString(R.styleable.SkyTimeBackgroundView_planetType);
    if(s != null) {
        switch (s) {
            case SUN:
                mPlanetType = SUN;
                break;
            case RED_SUN:
                mPlanetType = RED_SUN;
                break;
            case MOON:
                mPlanetType = MOON;
                break;
        }
    } else {
        mPlanetType = SUN;
    }

    planetPosition = mArray.getInt(R.styleable.SkyTimeBackgroundView_planetPosition, 0);
    mPlanetSpeed = mArray.getInt(R.styleable.SkyTimeBackgroundView_planetSpeed, 300);

    mAnimationIndex = planetPosition;

    mArray.recycle();

    if(mPlanetType.equals(SUN)) {
        setTime(Time.AFTERNOON);
    } else if(mPlanetType.equals(RED_SUN)) {
        setTime(Time.EARLY_NIGHT);
    } else if(mPlanetType.equals(MOON)) {
        setTime(Time.NIGHT);
    }

    mPainter = new SkyViewGradientBackgroundPainter(this, mDrawables);
}
 
开发者ID:dsa28s,项目名称:TimeSkyBackground,代码行数:80,代码来源:SkyTimeBackgroundView.java

示例13: addArcAnimation

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
/**
 * Add arc above/below the circular target overlay.
 */
private void addArcAnimation(final Activity activity) {
    AppCompatImageView mImageView = new AppCompatImageView(activity);
    mImageView.setImageResource(R.drawable.ic_spotlight_arc);
    LayoutParams params = new LayoutParams(2 * (circleShape.getRadius() + extraPaddingForArc),
            2 * (circleShape.getRadius() + extraPaddingForArc));


    if (targetView.getPoint().y > getHeight() / 2) {//bottom
        if (targetView.getPoint().x > getWidth() / 2) {//Right
            params.rightMargin = getWidth() - targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc;
            params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc;
            params.gravity = Gravity.RIGHT | Gravity.BOTTOM;
        } else {
            params.leftMargin = targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc;
            params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc;
            params.gravity = Gravity.LEFT | Gravity.BOTTOM;
        }
    } else {//up
        mImageView.setRotation(180); //Reverse the view
        if (targetView.getPoint().x > getWidth() / 2) {//Right
            params.rightMargin = getWidth() - targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc;
            params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc;
            params.gravity = Gravity.RIGHT | Gravity.BOTTOM;
        } else {
            params.leftMargin = targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc;
            params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc;
            params.gravity = Gravity.LEFT | Gravity.BOTTOM;
        }

    }
    mImageView.postInvalidate();
    mImageView.setLayoutParams(params);
    addView(mImageView);

    PorterDuffColorFilter porterDuffColorFilter = new PorterDuffColorFilter(lineAndArcColor,
            PorterDuff.Mode.SRC_ATOP);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        AnimatedVectorDrawable avd = (AnimatedVectorDrawable)
                ContextCompat.getDrawable(activity, R.drawable.avd_spotlight_arc);
        avd.setColorFilter(porterDuffColorFilter);
        mImageView.setImageDrawable(avd);
        avd.start();
    } else {
        AnimatedVectorDrawableCompat avdc =
                AnimatedVectorDrawableCompat.create(activity, R.drawable.avd_spotlight_arc);
        avdc.setColorFilter(porterDuffColorFilter);
        mImageView.setImageDrawable(avdc);
        avdc.start();
    }

    new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
        @Override
        public void run() {
            addPathAnimation(activity);
        }
    }, 400);
}
 
开发者ID:wooplr,项目名称:Spotlight,代码行数:61,代码来源:SpotlightView.java


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