Example usage for android.widget ImageView setLayoutParams

List of usage examples for android.widget ImageView setLayoutParams

Introduction

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

Prototype

public void setLayoutParams(ViewGroup.LayoutParams params) 

Source Link

Document

Set the layout parameters associated with this view.

Usage

From source file:org.alfresco.mobile.android.application.fragments.site.search.SearchSitesFragment.java

@Override
protected void prepareEmptyInitialView(View ev, ImageView emptyImageView, TextView firstEmptyMessage,
        TextView secondEmptyMessage) {/*ww w  . j  a  v a  2  s .  c  om*/
    emptyImageView.setLayoutParams(DisplayUtils.resizeLayout(getActivity(), 275, 275));
    emptyImageView.setImageResource(R.drawable.ic_empty_search_sites);
    firstEmptyMessage.setVisibility(View.GONE);
    secondEmptyMessage.setVisibility(View.GONE);
}

From source file:com.gudong.appkit.ui.fragment.ColorChooseDialog.java

private View getColorItemView(final Context context, int position, boolean isSelect) {
    int color = mColors[position];
    int widthImageCheckView = Utils.convertDensityPix(context, 24);
    int widthColorView = Utils.convertDensityPix(context, 56);
    int widthMargin = Utils.convertDensityPix(context, 4);

    ImageView imageView = new ImageView(context);
    imageView.setImageResource(R.drawable.ic_check);

    FrameLayout.LayoutParams ivParams = new FrameLayout.LayoutParams(widthImageCheckView, widthImageCheckView);
    ivParams.gravity = Gravity.CENTER;/*from  www  .  j a v  a  2 s .c  o  m*/
    imageView.setLayoutParams(ivParams);
    imageView.setVisibility(isSelect ? View.VISIBLE : View.INVISIBLE);

    FrameLayout frameLayout = new FrameLayout(context);
    GridLayout.LayoutParams params = new GridLayout.LayoutParams(
            new FrameLayout.LayoutParams(widthColorView, widthColorView));
    params.setGravity(Gravity.CENTER);
    params.setMargins(widthMargin, widthMargin, widthMargin, widthMargin);
    frameLayout.setLayoutParams(params);

    setBackgroundSelector(frameLayout, color);

    frameLayout.addView(imageView);
    frameLayout.setOnClickListener(this);
    frameLayout.setTag(position);
    return frameLayout;
}

From source file:com.ohso.util.ImageHandler.java

public void getImage(String url, ImageView imageView, Bitmap placeholder) {
    if (url == null) {
        imageView.setLayoutParams(mPlaceholderParams);
        imageView.setImageBitmap(placeholder);
        return;/*w  ww . j  ava2  s.  c  om*/
    }
    Bitmap bitmap = null;
    bitmap = mMemoryCache.get(getKey(url));
    if (bitmap != null) {
        imageView.setImageBitmap(bitmap);
    } else if (cancelPotentialWork(getKey(url), imageView)) {
        final ImageGetter imageGetter = new ImageGetter(imageView, url);
        final AsyncDrawable drawable = new AsyncDrawable(mResources, placeholder, imageGetter);
        imageView.setImageDrawable(drawable);
        imageGetter.executeOnExecutor(AsyncTask.DUAL_THREAD_EXECUTOR);
    }
}

From source file:org.alfresco.mobile.android.application.fragments.site.search.SearchSitesFragment.java

@Override
protected void prepareEmptyView(View ev, ImageView emptyImageView, TextView firstEmptyMessage,
        TextView secondEmptyMessage) {//from w w  w  .  j  a va  2 s  . c o m
    emptyImageView.setLayoutParams(DisplayUtils.resizeLayout(getActivity(), 275, 275));
    emptyImageView.setImageResource(R.drawable.ic_empty_search_sites);
    firstEmptyMessage.setVisibility(View.VISIBLE);
    firstEmptyMessage.setText(R.string.sites_search_empty_title);
    secondEmptyMessage.setVisibility(View.VISIBLE);
    secondEmptyMessage.setText(R.string.sites_search_empty_description);
}

From source file:com.idt.ontomedia.geoconsum.fragments.DetailsBaseFragment.java

protected void setURL(Cursor _cursor, int _idTextViewTextURL, int _idTextViewTitleURL, int _idImageViewURL) {
    final String url = _cursor.getString(_cursor.getColumnIndex(DatabaseAdapter.COLUMN_URL));
    TextView textViewText = (TextView) mParentActivity.findViewById(_idTextViewTextURL);
    TextView textviewTitle = (TextView) mParentActivity.findViewById(_idTextViewTitleURL);
    ImageView imageViewUrl = (ImageView) mParentActivity.findViewById(_idImageViewURL);

    if (url.length() != 0) {
        textViewText.setVisibility(View.VISIBLE);
        textviewTitle.setVisibility(View.VISIBLE);
        imageViewUrl.setVisibility(View.VISIBLE);
        imageViewUrl.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

        imageViewUrl.setOnClickListener(new OnClickListener() {

            @Override/*from   w  w w .  j av a2 s  . co m*/
            public void onClick(View v) {
                String httpURL = url;

                if (!url.startsWith("http")) {
                    httpURL = "http://" + url;
                }
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(httpURL));
                startActivity(intent);
            }
        });
    }
}

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   w w  w.  j  a v a 2s  .c  o  m*/

    }
}

From source file:com.sinelead.car.club.map.AMapEx.java

@Override
public View makeView() {
    ImageView iv = new ImageView(context);
    iv.setScaleType(ImageView.ScaleType.CENTER);
    iv.setLayoutParams(new ImageSwitcher.LayoutParams(ImageSwitcher.LayoutParams.MATCH_PARENT,
            ImageSwitcher.LayoutParams.MATCH_PARENT));
    return iv;/* www.  j  a v a2  s.  com*/
}

From source file:com.jasonchen.microlang.view.SlidingTabLayout.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   ww w .j  a va  2s  . c om*/
 */
protected View createDefaultTabView(Context context) {
    View v;
    if (mIconAdapter == null) {
        TextView textView = new TextView(context);
        textView.setGravity(Gravity.CENTER);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
        textView.setTypeface(Typeface.DEFAULT_BOLD);
        textView.setAllCaps(true);
        textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        v = textView;
    } else {
        ImageView imgView = new TintImageView(context);
        imgView.setScaleType(ImageView.ScaleType.FIT_XY);
        imgView.setLayoutParams(new LinearLayout.LayoutParams(mTabIconSize, mTabIconSize));
        v = imgView;
    }

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    v.setBackgroundResource(outValue.resourceId);

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

    return v;
}

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

/**
 * Fills "amount of planets" textView as well as drawing the planets
 *//*from   www.  ja va 2s  .c  o  m*/
private void drawPlanets() {
    //TODO use the bundle
    int numberOfPlanets = (int) (TOTAL_CO2 / MAX_CO2_PER_PERSON);
    TextView need = (TextView) findViewById(R.id.planetsTextView);
    need.setText("We would need " + numberOfPlanets + " planets");

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

    TableRow tbr = new TableRow(this);

    LinearLayout linearLayout = new LinearLayout(this);

    linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT, 1f)); //TODO

    tbr.setLayoutParams(
            new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT));
    tbr.setPadding(10, 10, 10, 10);

    for (int i = 1; i < numberOfPlanets + 1; i++) {
        // TODO: Too many planets fuck up formatting
        // Create images
        ImageView im = new ImageView(this);
        im.setImageResource(R.drawable.earth);
        im.setLayoutParams(
                new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));
        im.setPadding(10, 10, 10, 10);

        //planets per row = 5
        if (i % 5 == 0) {
            // if you have gone 5 laps
            // print what you have
            linearLayout.addView(im);
            tbr.addView(linearLayout,
                    new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1f));

            layout.addView(tbr, new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,
                    TableLayout.LayoutParams.MATCH_PARENT));

            tbr = new TableRow(this);
            linearLayout = new LinearLayout(this);

            linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.MATCH_PARENT, 1f));

            tbr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,
                    TableRow.LayoutParams.MATCH_PARENT));
            tbr.setPadding(10, 10, 10, 10);
        } else {
            linearLayout.addView(im);
        }

    }

    tbr.addView(linearLayout,
            new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1f)); //

    layout.addView(tbr, new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,
            TableLayout.LayoutParams.MATCH_PARENT));
}

From source file:org.alfresco.mobile.android.application.fragments.node.search.DocumentFolderSearchFragment.java

@Override
protected void prepareEmptyView(View ev, ImageView emptyImageView, TextView firstEmptyMessage,
        TextView secondEmptyMessage) {/*from w ww  . j  a v  a  2 s  . c om*/
    emptyImageView.setLayoutParams(DisplayUtils.resizeLayout(getActivity(), 275, 275));
    emptyImageView.setImageResource(
            searchFolderOnly ? R.drawable.ic_empty_search_folders : R.drawable.ic_empty_search_documents);
    firstEmptyMessage.setText(R.string.node_search_empty_title);
    secondEmptyMessage.setVisibility(View.VISIBLE);
    secondEmptyMessage.setText(R.string.node_search_empty_description);
}