Example usage for android.widget ImageView setMinimumWidth

List of usage examples for android.widget ImageView setMinimumWidth

Introduction

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

Prototype

public void setMinimumWidth(int minWidth) 

Source Link

Document

Sets the minimum width of the view.

Usage

From source file:Main.java

@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public static void resizeImageView(Context ctx, ImageView imgView) {
    WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    int width;//w  w w .j  av  a 2  s. c  om
    // int height;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) {
        width = display.getWidth(); // deprecated
        // height = display.getHeight(); // deprecated
    } else {
        Point size = new Point();
        display.getSize(size);
        width = size.x;
        // height = size.y;
    }

    imgView.setMinimumHeight(width);
    imgView.setMinimumWidth(width);
    imgView.getLayoutParams().height = width;
    imgView.getLayoutParams().width = width;
}

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);

    return imageView;

}

From source file:com.example.facebook_volley.Albums_photo.SlidingTabAlbum.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);

    return imageView;
}

From source file:com.rockerhieu.emojicon.slidingTab.SlidingTabLayout.java

/**
 * This method was custom added by Ivan, based on the post from
 * http://stackoverflow.com/questions/28125794/slidingtablayout-with-icons-only/28134763#28134763
 * @param context/*from w w w. ja v a 2  s  .c o  m*/
 * @return
 */
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);

    return imageView;
}

From source file:com.landenlabs.all_devtool.IconBaseFragment.java

/**
 * Show a 'LayerDrawable'  information./* www .  j  a va 2s  .com*/
 *
 * @param imageView
 * @param row1
 * @param row2
 * @param iconD
 * @param layerIdx
 */
private void showLayerIcon(final ImageView imageView, TableRow row1, TableRow row2, Drawable iconD,
        int layerIdx) {

    if (iconD != null) {
        ImageView layerImageView = new ImageView(imageView.getContext());

        layerImageView.setImageDrawable(iconD);
        layerImageView.setPadding(10, 10, 10, 10);
        layerImageView.setMinimumHeight(8);
        layerImageView.setMinimumWidth(8);
        layerImageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                imageView.setImageDrawable(((ImageView) v).getDrawable());
            }
        });

        TextView stateTextView = new TextView(imageView.getContext());
        stateTextView.setText(String.valueOf(layerIdx));
        stateTextView.setTextSize(12);
        stateTextView.setGravity(Gravity.CENTER);

        row1.addView(stateTextView);
        row2.addView(layerImageView);
    }
}

From source file:com.example.igorklimov.popularmoviesdemo.helpers.CustomAdapter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    Log.d(LOG_TAG, "onCreateViewHolder: ");
    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_movie, parent, false);
    ImageView posterImageView = (ImageView) view.findViewById(R.id.poster);
    boolean isTablet = Utility.isTabletPreference(mContext);
    if (mMinWidth == 0) {
        if (isTablet && mOrientation == Configuration.ORIENTATION_PORTRAIT) {
            mMinHeight = mRecyclerView.getHeight();
            mMinWidth = (int) (((double) mMinHeight / 278) * 185);
        } else {//  w ww  .  j  a  va 2  s. c  o  m
            mMinWidth = mRecyclerView.getWidth()
                    / (mOrientation == Configuration.ORIENTATION_LANDSCAPE || isTablet ? 3 : 2);
            mMinHeight = (int) (((double) mMinWidth / 185) * 278);
        }
    }
    posterImageView.setMinimumWidth(mMinWidth);
    posterImageView.setMinimumHeight(mMinHeight);
    return new ViewHolder(view);
}

From source file:com.jgraves.achievementunlocked.AchievementsList_Fragment.java

private void addAchievementToList(Long id, String name, int points) {
    Log.i(ExploraApp.TAG, "Adding achievement image request of id " + id + " with height, " + imageViewHeight);
    FrameLayout fl = new FrameLayout(getActivity());
    touchMap.put(fl, id);//w ww  .java  2  s.  c o m
    fl.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Long id = touchMap.get(v);
            Log.i(ExploraApp.TAG, "TOUCHED " + id);
            Intent intent = new Intent(getActivity(), Activity_AchievementInfo.class);
            intent.putExtra("achievement_id", Long.toString(id));
            startActivity(intent);
        }
    });
    TextView tv_name = new TextView(getActivity());
    TextView tv_points = new TextView(getActivity());
    ImageView iv = new ImageView(getActivity());
    fl.setMinimumHeight(imageViewHeight);
    fl.setMinimumWidth(ExploraApp.screenWidth);
    robotoTypeface = Typeface.createFromAsset(getActivity().getAssets(), "Roboto-Thin.ttf");
    tv_name.setText(name);
    tv_name.setTextSize(15f);
    tv_points.setTextSize(15f);
    tv_name.setTypeface(robotoTypeface);
    tv_points.setTypeface(robotoTypeface);
    tv_points.setText(Integer.toString(points));
    tv_points.setGravity(Gravity.RIGHT);
    tv_points.setTextColor(Color.WHITE);
    tv_name.setTextColor(Color.WHITE);
    iv.setMinimumHeight(imageViewHeight);
    iv.setMinimumWidth(ExploraApp.screenWidth);
    fl.addView(iv);
    fl.addView(tv_name);
    fl.addView(tv_points);
    ll_images_container.addView(fl);
    sv_images.bringChildToFront(mQuickReturnView);
    DefaultImageListener listener = new DefaultImageListener(iv);
    ImageRequest imageRequest = new ImageRequest(
            ExploraApp.url_main + "/achievement/" + id + "/photo?y=" + imageViewHeight + "&x="
                    + ExploraApp.screenWidth,
            listener, ExploraApp.screenWidth, imageViewHeight, Bitmap.Config.ARGB_8888, listener);
    ExploraApp.mRequestQueue.add(imageRequest);
}

From source file:com.yadadeya.yadadeya.widget.SlidingTabLayout.java

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

    //imageView.setGravity(Gravity.CENTER);
    //imageView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    //imageView.setTypeface(Typeface.DEFAULT_BOLD);
    //imageView.setLayoutParams(new LinearLayout.LayoutParams(
    //ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

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

    int width = (int) (getResources().getDisplayMetrics().widthPixels / 5);
    imageView.setMinimumWidth(width);

    return imageView;
}

From source file:onion.chat.MainActivity.java

void showQR() {
    String name = db.getName();//ww w. j  av  a2 s . c om
    String txt = "Its Ur's " + tor.getID() + " " + name;

    QRCode qr;

    try {
        //qr = Encoder.encode(txt, ErrorCorrectionLevel.H);
        qr = Encoder.encode(txt, ErrorCorrectionLevel.M);
    } catch (Exception ex) {
        throw new Error(ex);
    }

    ByteMatrix mat = qr.getMatrix();
    int width = mat.getWidth();
    int height = mat.getHeight();
    int[] pixels = new int[width * height];
    for (int y = 0; y < height; y++) {
        int offset = y * width;
        for (int x = 0; x < width; x++) {
            pixels[offset + x] = mat.get(x, y) != 0 ? Color.BLACK : Color.WHITE;
        }
    }
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    bitmap.setPixels(pixels, 0, width, 0, 0, width, height);

    bitmap = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth() * 8, bitmap.getHeight() * 8, false);

    ImageView view = new ImageView(this);
    view.setImageBitmap(bitmap);

    int pad = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16,
            getResources().getDisplayMetrics());
    view.setPadding(pad, pad, pad, pad);

    Rect displayRectangle = new Rect();
    Window window = getWindow();
    window.getDecorView().getWindowVisibleDisplayFrame(displayRectangle);
    int s = (int) (Math.min(displayRectangle.width(), displayRectangle.height()) * 0.9);
    view.setMinimumWidth(s);
    view.setMinimumHeight(s);
    new AlertDialog.Builder(this)
            //.setMessage(txt)
            .setView(view).show();
}

From source file:co.mrktplaces.android.ui.views.smarttablayout.SmartTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//from www .  j  av a2  s  .c  o  m
 */
protected ImageView createDefaultTabView(int resource) {
    ImageView imageView = new ImageView(getContext());
    imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    imageView.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1));
    imageView.setImageResource(resource);
    if (tabViewBackgroundResId != NO_ID) {
        imageView.setBackgroundResource(tabViewBackgroundResId);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        imageView.setBackgroundResource(outValue.resourceId);
    }

    imageView.setPadding(tabViewTextHorizontalPadding, 0, tabViewTextHorizontalPadding, 0);

    if (tabViewTextMinWidth > 0) {
        imageView.setMinimumWidth(tabViewTextMinWidth);
    }

    return imageView;
}