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.huyn.demogroup.relativetop.PagerSlidingTabStrip.java

private void addIconTab(final int position, int resId) {
    ImageView tab = new ImageView(getContext());
    tab.setImageBitmap(iProvider.getBitmap(resId));

    addTab(position, tab);/*from   w ww.  j av  a2  s. c o  m*/
}

From source file:com.mumu.joshautomation.HeadService.java

private void initGamePanelViews() {
    mHeadIconList = new ArrayList<>();
    mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);

    // Head Icon//from  w  w  w  .  ja  v  a2s .  co m
    HeadIconView headIcon = new HeadIconView(new ImageView(this), mWindowManager, 0, 0);
    headIcon.getImageView().setImageResource(R.mipmap.ic_launcher);
    headIcon.setOnTapListener(new HeadIconView.OnTapListener() {
        @Override
        public void onTap(View view) {
            configHeadIconShowing(
                    (getCurrentHeadIconVisibility() == HeadIconView.VISIBLE ? HeadIconView.INVISIBLE
                            : HeadIconView.VISIBLE));
        }

        @Override
        public void onLongPress(View view) {
            showExitConfirmDialog();
        }
    });
    mHeadIconList.add(headIcon);

    // Message Text Icon
    HeadIconView msgText = new HeadIconView(new TextView(this), mWindowManager, 140, 45);
    msgText.getTextView().setTextColor(Color.BLACK);
    msgText.getView().setBackgroundColor(Color.WHITE);
    mHeadIconList.add(msgText);

    // Capture Icon
    HeadIconView captureIcon = new HeadIconView(new ImageView(this), mWindowManager, 0, 120);
    captureIcon.getImageView().setImageResource(R.drawable.ic_menu_camera);
    captureIcon.setOnTapListener(new HeadIconView.OnTapListener() {
        @Override
        public void onTap(View view) {
            configCapture();
        }

        @Override
        public void onLongPress(View view) {

        }
    });
    mHeadIconList.add(captureIcon);

    // Setting Icon
    HeadIconView settingIcon = new HeadIconView(new ImageView(this), mWindowManager, 120, 120);
    settingIcon.getImageView().setImageResource(R.drawable.ic_menu_settings);
    settingIcon.setOnTapListener(new HeadIconView.OnTapListener() {
        @Override
        public void onTap(View view) {
            configSettings(false);
        }

        @Override
        public void onLongPress(View view) {
            Log.d(TAG, "config setting icon");
            configSettings(true);
        }
    });
    mHeadIconList.add(settingIcon);

    // Start and Stop control Icon
    HeadIconView startIcon = new HeadIconView(new ImageView(this), mWindowManager, 240, 120);
    startIcon.getImageView().setImageResource(R.drawable.ic_play);
    startIcon.setOnTapListener(new HeadIconView.OnTapListener() {
        @Override
        public void onTap(View view) {
            configScriptStatus();
        }

        @Override
        public void onLongPress(View view) {

        }
    });
    mHeadIconList.add(startIcon);

    // Share the same on move listener for moving at the same time
    HeadIconView.OnMoveListener moveListener = new HeadIconView.OnMoveListener() {
        @Override
        public void onMove(HeadIconView view, int initialX, int initialY, float initialTouchX,
                float initialTouchY, MotionEvent event) {
            // we limit the initiator of moving to only head icon
            if (view == mHeadIconList.get(IDX_HEAD_ICON)) {
                for (HeadIconView icon : mHeadIconList) {
                    icon.moveIconDefault(initialX, initialY, initialTouchX, initialTouchY, event);
                }
            }
        }
    };

    // Set all to add
    for (HeadIconView icon : mHeadIconList) {
        icon.addView();
        icon.setOnMoveListener(moveListener);
    }

    // Set default visibility
    configHeadIconShowing(HeadIconView.VISIBLE);
}

From source file:com.example.hllut.app.Deprecated.MainActivity.java

/**
 * fill the "liters of petrol" textView, as well as drawing the petrol barrels
 *//*from w  ww  . j  a  v  a2s. c  om*/
private void drawPetrol() {
    //TODO use the bundle
    float litersOfPetrol = (TOTAL_CO2 / CO2_PER_LITRE_PETROL);

    TextView tv = (TextView) findViewById(R.id.litersTextView);
    tv.setText("Burning " + String.format("%.2f", litersOfPetrol) + " liters of petrol");

    TableLayout layout = (TableLayout) findViewById(R.id.petrolContainer);

    TableRow newRow = new TableRow(this);
    LinearLayout linLay = new LinearLayout(this);

    linLay.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT, 1f));

    newRow.setLayoutParams(
            new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
    newRow.setPadding(10, 10, 10, 10);

    for (int i = 1; i < (int) litersOfPetrol + 1; i++) { //
        // TODO: To many images fuck up formatting
        // Create images
        ImageView im = new ImageView(this);
        im.setImageResource(R.drawable.oil_barrel);
        im.setLayoutParams(
                new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));

        //barrells per row = 7
        if (i % 7 == 0) {
            // if you have gone 7 laps
            // print what you have
            linLay.addView(im);
            newRow.addView(linLay,
                    new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));

            layout.addView(newRow, new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,
                    TableLayout.LayoutParams.WRAP_CONTENT));

            newRow = new TableRow(this);
            linLay = new LinearLayout(this);

            linLay.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT, 1f));

            newRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                    TableRow.LayoutParams.WRAP_CONTENT));
            newRow.setPadding(10, 10, 10, 10);
        } else {
            linLay.addView(im);
        }

    }

    newRow.addView(linLay, new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));

    layout.addView(newRow, new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,
            TableLayout.LayoutParams.WRAP_CONTENT));
}

From source file:ironblossom.csemock.experimental.utils.SlidingTabLayout.java

private void populateTabIcon() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final OnClickListener tabClickListener = new TabClickListener();

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(0,
            LinearLayout.LayoutParams.WRAP_CONTENT, 1f);
    int margin = (int) (10 * ExMainActivity.densityFactor);
    layoutParams.setMargins(0, margin, 0, margin);

    final int[] tabIcons = new int[] { R.drawable.ic_overview, R.drawable.ic_market_info,
            R.drawable.ic_watchlist, R.drawable.ic_portfolio };

    for (int i = 0; i < adapter.getCount(); i++) {
        ImageView tabIconView = new ImageView(getContext());
        tabIconView.setImageResource(tabIcons[i]);
        tabIconView.setLayoutParams(layoutParams);

        tabIconView.setOnClickListener(tabClickListener);
        mTabStrip.addView(tabIconView);//from  ww  w.  java2s . c  om

    }
}

From source file:com.example.admin.viewpageexample.SlidingTab.SlidingTabLayout.java

protected ImageView createDefaultImageView(Context context) {
    ImageView imageView = new ImageView(context);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    imageView.setPadding(padding, padding, padding, padding);

    int width = (int) (getResources().getDisplayMetrics().widthPixels / mViewPager.getAdapter().getCount());
    imageView.setMinimumWidth(width);// w  ww. j a  v  a2 s .  co  m

    return imageView;

}

From source file:com.uzmap.pkg.uzmodules.uzBMap.mode.Billboard.java

private ImageView icon() {
    ImageView icon = new ImageView(context);
    LayoutParams layoutParams = new LayoutParams(UZCoreUtil.dipToPix(iconSize), UZCoreUtil.dipToPix(iconSize));
    layoutParams.setMargins(UZCoreUtil.dipToPix(iconMarginLeft), UZCoreUtil.dipToPix(iconMarginTop),
            UZCoreUtil.dipToPix(iconMarginLeft), UZCoreUtil.dipToPix(iconMarginTop));
    icon.setLayoutParams(layoutParams);//from  www.  j  a  v  a  2s  .c  o m
    if (getIcon() != null) {
        icon.setImageBitmap(getIcon());
    } else {
        getImgShowUtil().display(icon, iconStr, getLoadCallBack());
    }
    return icon;
}

From source file:com.nextgis.mobile.MapFragment.java

protected void addMapButtons(RelativeLayout rl) {
    mivZoomIn = new ImageView(getActivity());
    mivZoomIn.setImageResource(R.drawable.ic_plus);
    //mivZoomIn.setId(R.drawable.ic_plus);

    mivZoomOut = new ImageView(getActivity());
    mivZoomOut.setImageResource(R.drawable.ic_minus);
    //mivZoomOut.setId(R.drawable.ic_minus);

    final ImageView ivMark = new ImageView(getActivity());
    ivMark.setImageResource(R.drawable.ic_mark);
    //ivMark.setId(R.drawable.ic_mark);

    //show zoom level between plus and minus
    mivZoomLevel = new TextView(getActivity());
    //ivZoomLevel.setAlpha(150);
    mivZoomLevel.setId(R.drawable.ic_zoomlevel);

    final float scale = getResources().getDisplayMetrics().density;
    int pixels = (int) (48 * scale + 0.5f);

    mivZoomLevel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
    //ivZoomLevel.setTextAppearance(this, android.R.attr.textAppearanceLarge);

    mivZoomLevel.setWidth(pixels);/*from w ww  .  j av  a  2 s  .  co m*/
    mivZoomLevel.setHeight(pixels);
    mivZoomLevel.setTextColor(Color.DKGRAY);
    mivZoomLevel.setBackgroundColor(Color.argb(50, 128, 128, 128)); //Color.LTGRAY R.drawable.ic_zoomlevel);
    mivZoomLevel.setGravity(Gravity.CENTER);
    mivZoomLevel.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    mivZoomLevel.setText("" + (int) Math.floor(mMap.getZoomLevel()));

    mivZoomIn.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mMap.zoomIn();
        }
    });

    mivZoomOut.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mMap.zoomOut();
        }
    });

    ivMark.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            //TODO: onMark();
        }
    });

    final RelativeLayout.LayoutParams RightParams1 = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RightParams1.setMargins(mMargings + 5, mMargings - 5, mMargings + 5, mMargings - 5);
    RightParams1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    RightParams1.addRule(RelativeLayout.CENTER_IN_PARENT);//ALIGN_PARENT_TOP
    rl.addView(mivZoomLevel, RightParams1);

    final RelativeLayout.LayoutParams RightParams4 = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RightParams4.setMargins(mMargings + 5, mMargings - 5, mMargings + 5, mMargings - 5);
    RightParams4.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    RightParams4.addRule(RelativeLayout.ABOVE, R.drawable.ic_zoomlevel);//ALIGN_PARENT_TOP
    rl.addView(mivZoomIn, RightParams4);

    final RelativeLayout.LayoutParams RightParams3 = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RightParams3.setMargins(mMargings + 5, mMargings - 5, mMargings + 5, mMargings - 5);
    RightParams3.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    RightParams3.addRule(RelativeLayout.CENTER_IN_PARENT);//ALIGN_PARENT_TOP
    rl.addView(ivMark, RightParams3);

    final RelativeLayout.LayoutParams RightParams2 = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RightParams2.setMargins(mMargings + 5, mMargings - 5, mMargings + 5, mMargings - 5);
    RightParams2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    RightParams2.addRule(RelativeLayout.BELOW, R.drawable.ic_zoomlevel);//R.drawable.ic_plus);
    rl.addView(mivZoomOut, RightParams2);

    setZoomInEnabled(mMap.canZoomIn());
    setZoomOutEnabled(mMap.canZoomOut());
}

From source file:com.alex.view.loop.IndicatorView.java

/**
 * /*from   w  w  w. j a va  2s  .  c  o  m*/
 *
 * @return
 */
private View makeIndicatorItem() {
    ImageView iv = new ImageView(getContext());
    LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    lp.width = normalBp.getWidth();
    lp.height = normalBp.getHeight();
    lp.rightMargin = mInterval;
    iv.setImageBitmap(normalBp);
    iv.setLayoutParams(lp);
    return iv;
}

From source file:com.joravasal.comicagg.ComicDetailFragment.java

@SuppressLint({ "NewApi" })
@Override//from  w w w . j  a  v a  2s . co m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_comic_detail, container, false);
    if (comicItem == null && savedInstanceState.containsKey(ARG_ITEM_ID)) {
        comicItem = new ComicItem(savedInstanceState.getString(ARG_ITEM_ID),
                savedInstanceState.getString("comicname"), savedInstanceState.getString("comicurl"),
                savedInstanceState.getString("unreadcount"));
    }
    int unread = Integer.parseInt(comicItem.unreadCount);
    if (unread == 0) {
        rootView.findViewById(R.id.vote_bar).setVisibility(View.GONE);
    }
    LinearLayout stripList = (LinearLayout) rootView.findViewById(R.id.strips_list);
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

    if (comicItem.id.equals(ComicStripsContent.id) && ComicStripsContent.ITEMS.size() > unread) {
        unread = ComicStripsContent.ITEMS.size();
    }
    for (int i = 1; i < unread; i++) {
        ImageView iv = new ImageView(getActivity());
        iv.setId(Integer.MAX_VALUE - i);
        iv.setPadding(16, 16, 16, 0);
        iv.setContentDescription(getString(R.string.strip_description));
        iv.setAdjustViewBounds(true);

        iv.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO check if there is need of opening? or always open?
                openFullscreenStrip(v);
            }
        });

        TextView tv = new TextView(getActivity());
        tv.setId(i);
        tv.setPadding(16, 4, 16, 4);
        tv.setGravity(Gravity.CENTER);

        stripList.addView(iv, layoutParams);
        stripList.addView(tv, layoutParams);
    }

    if (!comicItem.id.equals(ComicStripsContent.id)) {
        new GetComicsStrips(comicItem.id, unread, rootView).execute();
    } else {
        new GetComicsStrips(comicItem.id, unread, rootView).onPostExecute(null);
    }
    if (savedInstanceState != null && savedInstanceState.containsKey(VERTICAL_SCROLLING_POSITION)
            && VERSION.SDK_INT >= 14) {
        rootView.findViewById(R.id.comic_scrollView).scrollTo(0,
                savedInstanceState.getInt(VERTICAL_SCROLLING_POSITION));
    }
    return rootView;
}