Example usage for android.widget ImageView ImageView

List of usage examples for android.widget ImageView ImageView

Introduction

In this page you can find the example usage for android.widget ImageView ImageView.

Prototype

public ImageView(Context context) 

Source Link

Usage

From source file:com.learn.mobile.customview.DSwipeRefreshLayout.java

private void createProgressView() {
    mCircleView = new DCircleImageView(getContext(), CIRCLE_BG_LIGHT, CIRCLE_DIAMETER / 2);
    mProgress = new DMaterialProgressDrawable(getContext(), this);
    mProgress.setBackgroundColor(CIRCLE_BG_LIGHT);
    mCircleView.setImageDrawable(mProgress);
    mCircleView.setVisibility(View.GONE);
    addView(mCircleView);/* w ww .j a va 2 s.co m*/

    // TODO Create backdrop
    backDrop = new ImageView(getContext());

    backDrop.setVisibility(View.GONE);
    backDrop.bringToFront();
    backDrop.setBackgroundColor(Color.WHITE);
    addView(backDrop);

    // TODO Custom Swipe Refresh Layout
    mLoadMoreCircleView = new DCircleImageView(getContext(), CIRCLE_BG_LIGHT, CIRCLE_DIAMETER / 2);
    mLoadMoreProgress = new DMaterialProgressDrawable(getContext(), mLoadMoreCircleView);
    mLoadMoreProgress.setBackgroundColor(CIRCLE_BG_LIGHT);
    mLoadMoreProgress.setColorSchemeColors(Color.BLUE, Color.RED, Color.GREEN, Color.WHITE, Color.BLACK);

    mLoadMoreCircleView.setImageDrawable(mLoadMoreProgress);

    mLoadMoreCircleView.setVisibility(View.GONE);

    addView(mLoadMoreCircleView);

    mLoadMoreProgress.setAlpha(MAX_ALPHA);

}

From source file:com.github.takumalee.simplematerialtabpager.view.PagerSlidingTabStrip.java

private View addIconTab(final int position, int resId) {

    ImageView tab = new ImageView(getContext());
    tab.setImageResource(resId);//from  ww  w .j a v a 2s .c om
    tab.setPadding(0, iconPaddingTop, 0, iconPaddingBottom);

    addTab(position, tab);
    return tab;

}

From source file:com.vk.sdk.dialogs.VKShareDialog.java

private void addBitmapToPreview(Bitmap sourceBitmap) {
    if (getActivity() == null)
        return;// w ww . j a v  a2s. c  o  m
    Bitmap b = VKUIHelper.getRoundedCornerBitmap(sourceBitmap, SHARE_PHOTO_HEIGHT, SHARE_PHOTO_CORNER_RADIUS);
    if (b == null)
        return;
    ImageView iv = new ImageView(getActivity());
    iv.setImageBitmap(b);
    iv.setAdjustViewBounds(true);

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    params.setMargins(mPhotoLayout.getChildCount() > 0 ? SHARE_PHOTO_MARGIN_LEFT : 0, 0, 0, 0);

    mPhotoLayout.addView(iv, params);
    mPhotoLayout.invalidate();
    mPhotoScroll.invalidate();
}

From source file:com.hiyjeain.android.DevBase.widget.DoubleSwipeRefreshLayout.java

private void createMoreView() {

    mMoreImageView = new ImageView(getContext());
    mMoreImageView.setBackgroundResource(android.R.color.transparent);

    mMoreProgress = new MaterialProgressDrawable(getContext(), mMoreImageView);
    mMoreProgress.setBackgroundColor(getResources().getColor(android.R.color.transparent));
    mMoreProgress.setAlpha(MAX_ALPHA);//w  ww  . ja  v  a 2  s. com

    mMoreImageView.setImageDrawable(mMoreProgress);
    mMoreImageView.setVisibility(View.VISIBLE);

    mMoreProgress.start();

    addView(mMoreImageView);
}

From source file:com.scigames.slidegame.Registration2RFIDActivity.java

public void onActivityResult(int requestCode, Intent data) {
    //public void onActivityResult(int requestCode, int resultCode, Intent data) {     
    super.onActivityResult(requestCode, 1, data);
    Log.d(TAG, "...super.onActivityResult");
    switch (requestCode) {

    case (0): {//from w ww.j a  va 2s. c o  m
        Log.d(TAG, "...case(0)");
        //if (resultCode == Activity.RESULT_OK) { 
        //  Log.d(TAG,"...RESULT_OK");

        ImageView previewThumbnail = new ImageView(this);
        Log.d(TAG, "...newImageView");

        Bitmap b = BitmapFactory.decodeByteArray(getIntent().getByteArrayExtra("byteArray"), 0,
                getIntent().getByteArrayExtra("byteArray").length);
        Log.d(TAG, "...BitmapFactory.decodeByteArray");

        previewThumbnail.setImageBitmap(b);
        Log.d(TAG, "...setImageBitmap");

        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(30, 30);
        Log.d(TAG, "...new layoutparams");

        previewThumbnail.setLayoutParams(layoutParams);
        Log.d(TAG, "...setLayoutParams");
        //}
        break;
    }
    }
}

From source file:com.example.fan.horizontalscrollview.PagerSlidingTabStrip.java

private void addWarningTab(final int position, String title, int resId) {
    LinearLayout tabLayout = new LinearLayout(getContext());
    tabLayout.setOrientation(LinearLayout.HORIZONTAL);
    tabLayout.setGravity(Gravity.CENTER);

    ImageView tabImg = new ImageView(getContext());
    int width = DimenUtils.dp2px(getContext(), 18);
    LinearLayout.LayoutParams tabImgParams = new LinearLayout.LayoutParams(width, width);
    tabImgParams.setMargins(0, 0, DimenUtils.dp2px(getContext(), 10), 0);
    tabImgParams.gravity = Gravity.CENTER;
    tabImg.setLayoutParams(tabImgParams);
    if (resId != -1) {
        tabImg.setBackgroundResource(resId);
        tabImg.setVisibility(View.VISIBLE);
    } else {//from w w  w  . j av  a  2  s  .c  o m
        tabImg.setVisibility(View.GONE);
    }
    tabLayout.addView(tabImg, 0);

    TextView tab = new TextView(getContext());
    tab.setText(title);
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tab.setTextColor(getResources().getColorStateList(
            mTextChangeable ? R.color.pst_tab_changeable_text_selector : R.color.pst_tab_text_selector));
    tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18.0f);
    tabLayout.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (null != mOnPageClickedLisener) {
                mOnPageClickedLisener.onPageClicked(position);
            }
            pager.setCurrentItem(position);
        }
    });
    tabLayout.addView(tab, 1);

    tabsContainer.addView(tabLayout);
}

From source file:net.henryco.opalette.application.MainActivity.java

@Override
public void setResultBitmap(Bitmap bitmap) {

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);

    ImageView imageView = new ImageView(this);
    imageView.setImageBitmap(bitmap);/*www. ja v a 2 s  .  c o  m*/
    String name = GodConfig.genDefaultImgFileName();
    new OPallAlertDialog().title("").content(imageView)
            .positive(getResources().getString(R.string.save), () -> {
                View v = new LinearLayout(this);
                OPallViewInjector.inject(this, new OPallViewInjector<AppMainProto>(v, R.layout.textline) {
                    @Override
                    protected void onInject(AppMainProto context, View view) {
                        TextView imageNameLine = (TextView) view.findViewById(R.id.lineText);
                        imageNameLine.setInputType(InputType.TYPE_CLASS_TEXT);
                        imageNameLine.setText(name);
                        new OPallAlertDialog().title(getResources().getString(R.string.save_as)).content(v)
                                .positive(getResources().getString(R.string.save), () -> {
                                    Utils.saveBitmapAction(bitmap, imageNameLine.getText().toString(),
                                            context.getActivityContext());
                                    createSaveSuccessNotification(context.getActivityContext(), name);
                                }).negative(getResources().getString(R.string.cancel))
                                .show(getSupportFragmentManager(), "Bitmap save");
                    }
                });
            })
            .negative(getResources().getString(R.string.share),
                    () -> Utils.shareBitmapAction(bitmap, name, this,
                            preferences.getBoolean(GodConfig.PREF_KEY_SAVE_AFTER, false),
                            () -> createSaveSuccessNotification(this, name)))
            .neutral(getResources().getString(R.string.cancel))
            .show(getSupportFragmentManager(), "Bitmap preview");
}

From source file:com.teitsmch.hearthmaker.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.navigation_drawer, menu);

    final MenuItem item = menu.findItem(R.id.action_search);
    //item.setActionView(R.layout.iv_rotate);
    //ImageView refresh = (ImageView) item.getActionView();
    final ImageView image = new ImageView(this);
    ViewGroup.MarginLayoutParams layoutParams = new ViewGroup.MarginLayoutParams(
            ViewGroup.MarginLayoutParams.WRAP_CONTENT, ViewGroup.MarginLayoutParams.WRAP_CONTENT);
    image.setLayoutParams(layoutParams);
    image.setImageResource(R.drawable.ic_filter_list_24dp);
    int padding_in_dp = 16;
    final float scale = getResources().getDisplayMetrics().density;
    int padding_in_px = (int) (padding_in_dp * scale + 0.5f);
    image.setPadding(padding_in_px, 0, padding_in_px, 0);

    image.setOnClickListener(new View.OnClickListener() {
        @Override// w ww  .  j  a v  a  2  s  .  c o m
        public void onClick(View v) {
            if (mSpinnerView.getVisibility() == View.VISIBLE)
                image.setImageResource(R.drawable.rev_ic_filter_list_24dp);
            else
                image.setImageResource(R.drawable.ic_filter_list_24dp);

            onOptionsItemSelected(item);
        }
    });
    item.setActionView(image);

    if (mFragment.getClass() == CardViewFragment.class) {
        menu.findItem(MENU_ITEM_RENAME).setVisible(false);
        menu.findItem(MENU_ITEM_CLEAR).setVisible(false);
        menu.findItem(MENU_ITEM_DELETE).setVisible(false);
        menu.findItem(R.id.class_icon).setVisible(false);
    } else {
        menu.findItem(MENU_ITEM_RENAME).setVisible(true);
        menu.findItem(MENU_ITEM_CLEAR).setVisible(true);
        menu.findItem(MENU_ITEM_DELETE).setVisible(true);
        menu.findItem(R.id.class_icon).setVisible(true);
        menu.findItem(R.id.class_icon).setIcon(classIcon);
    }

    return super.onCreateOptionsMenu(menu);
}

From source file:com.android.systemui.statusbar.phone.NavigationBarView.java

private void addLightsOutButton(LinearLayout root, View v, boolean landscape, boolean empty) {

    ImageView addMe = new ImageView(mContext);
    addMe.setLayoutParams(v.getLayoutParams());
    addMe.setImageResource(/*from w w w  .jav a 2 s  .  c om*/
            empty ? R.drawable.ic_sysbar_lights_out_dot_large : R.drawable.ic_sysbar_lights_out_dot_small);
    addMe.setScaleType(ImageView.ScaleType.CENTER);
    addMe.setVisibility(empty ? View.INVISIBLE : View.VISIBLE);

    if (landscape)
        root.addView(addMe, 0);
    else
        root.addView(addMe);

}

From source file:com.runkun.lbsq.fragment.StickyHeaderFragment2.java

public void add2Shopcart(View triggerView, GoodsCategoryCombineView2Test gccv) {
    String memberId = ConfigUtil.readString(getActivity(), MyConstant.KEY_MEMBERID, "");
    if (Tools.isEmpty(memberId)) {
        Tools.dialog(getActivity(), Tools.getStr(getActivity(), R.string.REQUESTLOGIN), true,
                new onButtonClick() {

                    @Override/*from  ww  w .  j a v  a 2s .  c  om*/
                    public void buttonClick() {
                        getActivity().startActivity(new Intent(getActivity(), LoginActivity.class));
                        AnimUtil.animToSlide(getActivity());
                    }
                });
    } else {
        RequestParams requestParams = new RequestParams();
        requestParams.addQueryStringParameter("goods_id", gccv.getGoodId());
        requestParams.addQueryStringParameter("quantity", gccv.getOrderCountTV().getText().toString().trim());
        requestParams.addQueryStringParameter("member_id", memberId);
        ImageView aniImg = new ImageView(getActivity());
        aniImg.setBackgroundDrawable(gccv.getGoodImgIV().getDrawable());
        Tools.addShopCard((BaseAcitivity) getActivity(), "addshopcar", triggerView,
                mainActivity.getShopcardLayout(), aniImg, requestParams, true);
    }

}