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:edu.stanford.mobisocial.dungbeetle.feed.objects.PictureObj.java

public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) {
    JSONObject content = obj.getJson();/*  ww w.j a v  a2 s. c  o  m*/
    byte[] raw = obj.getRaw();
    if (raw == null) {
        Pair<JSONObject, byte[]> p = splitRaw(content);
        content = p.first;
        raw = p.second;
    }
    ImageView imageView = new ImageView(context);
    imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    imageView.setImageBitmap(BitmapFactory.decodeByteArray(raw, 0, raw.length));
    //        App.instance().objectImages.lazyLoadImage(raw.hashCode(), raw, imageView);
    frame.addView(imageView);
}

From source file:me.chenjiayang.myleancloud.CarItemActivity.java

private void setAdapter() {
    //SimpleAdapter
    SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.list_car_info_elem, from, to);
    //ListActivitysetListAdapterListView?
    listView.setAdapter(adapter);/*from   w  w  w .j  a  v a  2  s .c  o  m*/
    listView.setOnItemClickListener(new ListItemClickListener());

    /**
     * 
     * ??LogoidR.id.home
     */
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(false);

    //???
    car_qr_btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                final Bitmap bitmap = EncodingHandler.createQRCode(carinfo, 900);
                final ImageView imageView = new ImageView(CarItemActivity.this);
                imageView.setImageBitmap(bitmap);
                builder = new AlertDialog.Builder(CarItemActivity.this);
                alert = builder.setView(imageView)
                        .setNegativeButton("?", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                            }
                        }).create();
                alert.show();
            } catch (WriterException e) {
                ToastUtil.show(CarItemActivity.this, "??");
            }
        }
    });

    car_delete_bound_btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            //sweet dialog
            new SweetAlertDialog(CarItemActivity.this, SweetAlertDialog.WARNING_TYPE)
                    .setTitleText("Are you sure?").setContentText("Won't be able to recover this car!")
                    .setConfirmText("Yes,delete it!")
                    .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
                        @Override
                        public void onClick(SweetAlertDialog sDialog) {
                            sDialog.setTitleText("Deleted!")
                                    .setContentText("Your imaginary car has been deleted!").setConfirmText("OK")
                                    .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
                                        @Override
                                        public void onClick(SweetAlertDialog sweetAlertDialog) {
                                            sweetAlertDialog.dismiss();
                                        }
                                    }).changeAlertType(SweetAlertDialog.SUCCESS_TYPE);

                            AVQuery<AVObject> avQuery = new AVQuery<>("Car");
                            avQuery.getInBackground(bundle_id.getString("ObjectId"),
                                    new GetCallback<AVObject>() {
                                        @Override
                                        public void done(AVObject avObject, AVException e) {
                                            if (AVUser.getCurrentUser().getString("NowDriving")
                                                    .equals(bundle_id.getString("ObjectId"))) {
                                                AVUser auser = AVUser.getCurrentUser();
                                                auser.put("NowDriving", "");
                                                auser.saveInBackground();
                                            }
                                            avObject.deleteInBackground();
                                            ToastUtil.show(CarItemActivity.this, "?");
                                        }
                                    });

                        }
                    }).show();
        }
    });
}

From source file:com.markupartist.sthlmtraveling.ui.view.TripView.java

public void updateViews() {
    this.setOrientation(VERTICAL);

    float scale = getResources().getDisplayMetrics().density;

    this.setPadding(getResources().getDimensionPixelSize(R.dimen.list_horizontal_padding),
            getResources().getDimensionPixelSize(R.dimen.list_vertical_padding),
            getResources().getDimensionPixelSize(R.dimen.list_horizontal_padding),
            getResources().getDimensionPixelSize(R.dimen.list_vertical_padding));

    LinearLayout timeStartEndLayout = new LinearLayout(getContext());
    TextView timeStartEndText = new TextView(getContext());
    timeStartEndText.setText(DateTimeUtil.routeToTimeDisplay(getContext(), trip));
    timeStartEndText.setTextColor(ContextCompat.getColor(getContext(), R.color.body_text_1));
    timeStartEndText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);

    ViewCompat.setPaddingRelative(timeStartEndText, 0, 0, 0, (int) (2 * scale));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (RtlUtils.isRtl(Locale.getDefault())) {
            timeStartEndText.setTextDirection(View.TEXT_DIRECTION_RTL);
        }//from   ww  w . jav  a  2s  . c  o  m
    }

    // Check if we have Realtime for start and or end.
    boolean hasRealtime = false;
    Pair<Date, RealTimeState> transitTime = trip.departsAt(true);
    if (transitTime.second != RealTimeState.NOT_SET) {
        hasRealtime = true;
    } else {
        transitTime = trip.arrivesAt(true);
        if (transitTime.second != RealTimeState.NOT_SET) {
            hasRealtime = true;
        }
    }
    //        if (hasRealtime) {
    //            ImageView liveDrawable = new ImageView(getContext());
    //            liveDrawable.setImageResource(R.drawable.ic_live);
    //            ViewCompat.setPaddingRelative(liveDrawable, 0, (int) (2 * scale), (int) (4 * scale), 0);
    //            timeStartEndLayout.addView(liveDrawable);
    //
    //            AlphaAnimation animation1 = new AlphaAnimation(0.4f, 1.0f);
    //            animation1.setDuration(600);
    //            animation1.setRepeatMode(Animation.REVERSE);
    //            animation1.setRepeatCount(Animation.INFINITE);
    //
    //            liveDrawable.startAnimation(animation1);
    //        }

    timeStartEndLayout.addView(timeStartEndText);

    LinearLayout startAndEndPointLayout = new LinearLayout(getContext());
    TextView startAndEndPoint = new TextView(getContext());
    BidiFormatter bidiFormatter = BidiFormatter.getInstance(RtlUtils.isRtl(Locale.getDefault()));
    startAndEndPoint.setText(String.format("%s  %s", bidiFormatter.unicodeWrap(trip.fromStop().getName()),
            bidiFormatter.unicodeWrap(trip.toStop().getName())));

    startAndEndPoint.setTextColor(getResources().getColor(R.color.body_text_1)); // Dark gray
    startAndEndPoint.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (RtlUtils.isRtl(Locale.getDefault())) {
            startAndEndPoint.setTextDirection(View.TEXT_DIRECTION_RTL);
        }
    }
    ViewCompat.setPaddingRelative(startAndEndPoint, 0, (int) (4 * scale), 0, (int) (4 * scale));
    startAndEndPointLayout.addView(startAndEndPoint);

    RelativeLayout timeLayout = new RelativeLayout(getContext());

    LinearLayout routeChanges = new LinearLayout(getContext());
    routeChanges.setGravity(Gravity.CENTER_VERTICAL);

    LinearLayout.LayoutParams changesLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    changesLayoutParams.gravity = Gravity.CENTER_VERTICAL;

    if (trip.hasAlertsOrNotes()) {
        ImageView warning = new ImageView(getContext());
        warning.setImageResource(R.drawable.ic_trip_deviation);
        ViewCompat.setPaddingRelative(warning, 0, (int) (2 * scale), (int) (4 * scale), 0);
        routeChanges.addView(warning);
    }

    int currentTransportCount = 1;
    int transportCount = trip.getLegs().size();
    for (Leg leg : trip.getLegs()) {
        if (!leg.isTransit() && transportCount > 3) {
            if (leg.getDistance() < 150) {
                continue;
            }
        }
        if (currentTransportCount > 1 && transportCount >= currentTransportCount) {
            ImageView separator = new ImageView(getContext());
            separator.setImageResource(R.drawable.transport_separator);
            ViewCompat.setPaddingRelative(separator, 0, 0, (int) (2 * scale), 0);
            separator.setLayoutParams(changesLayoutParams);
            routeChanges.addView(separator);
            if (RtlUtils.isRtl(Locale.getDefault())) {
                ViewCompat.setScaleX(separator, -1f);
            }
        }

        ImageView changeImageView = new ImageView(getContext());
        Drawable transportDrawable = LegUtil.getTransportDrawable(getContext(), leg);
        changeImageView.setImageDrawable(transportDrawable);
        if (RtlUtils.isRtl(Locale.getDefault())) {
            ViewCompat.setScaleX(changeImageView, -1f);
        }
        ViewCompat.setPaddingRelative(changeImageView, 0, 0, 0, 0);
        changeImageView.setLayoutParams(changesLayoutParams);
        routeChanges.addView(changeImageView);

        if (currentTransportCount <= 3) {
            String lineName = leg.getRouteShortName();
            if (!TextUtils.isEmpty(lineName)) {
                TextView lineNumberView = new TextView(getContext());
                lineNumberView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
                RoundedBackgroundSpan roundedBackgroundSpan = new RoundedBackgroundSpan(
                        LegUtil.getColor(getContext(), leg), Color.WHITE,
                        ViewHelper.dipsToPix(getContext().getResources(), 4));
                SpannableStringBuilder sb = new SpannableStringBuilder();
                sb.append(lineName);
                sb.append(' ');
                sb.setSpan(roundedBackgroundSpan, 0, lineName.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
                lineNumberView.setText(sb);

                ViewCompat.setPaddingRelative(lineNumberView, (int) (5 * scale), (int) (1 * scale),
                        (int) (2 * scale), 0);
                lineNumberView.setLayoutParams(changesLayoutParams);
                routeChanges.addView(lineNumberView);
            }
        }

        currentTransportCount++;
    }

    TextView durationText = new TextView(getContext());
    durationText.setText(DateTimeUtil.formatDetailedDuration(getResources(), trip.getDuration() * 1000));
    durationText.setTextColor(ContextCompat.getColor(getContext(), R.color.body_text_1));
    durationText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
    durationText.setTypeface(Typeface.DEFAULT_BOLD);

    timeLayout.addView(routeChanges);
    timeLayout.addView(durationText);

    RelativeLayout.LayoutParams durationTextParams = (RelativeLayout.LayoutParams) durationText
            .getLayoutParams();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        durationTextParams.addRule(RelativeLayout.ALIGN_PARENT_END);
    } else {
        durationTextParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    }
    durationText.setLayoutParams(durationTextParams);

    View divider = new View(getContext());
    ViewGroup.LayoutParams dividerParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1);
    divider.setLayoutParams(dividerParams);

    this.addView(timeLayout);

    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) routeChanges.getLayoutParams();
    params.height = LayoutParams.MATCH_PARENT;
    params.addRule(RelativeLayout.CENTER_VERTICAL);
    routeChanges.setLayoutParams(params);

    this.addView(startAndEndPointLayout);
    this.addView(timeStartEndLayout);

    if (mShowDivider) {
        this.addView(divider);
    }
}

From source file:com.facebook.notifications.internal.asset.handlers.BitmapAssetHandler.java

@NonNull
@Override//from  w w w .  jav  a2  s  . c  om
public View createView(@NonNull BitmapAsset asset, @NonNull Context context) {
    ImageView imageView = new ImageView(context);
    imageView.setImageBitmap(asset.getBitmap());
    imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
    imageView.setAdjustViewBounds(true);

    return imageView;
}

From source file:com.tarot.sdfnash.tarot.registnew.View.indicator.PageTabLabel.java

public ImageView getDivider() {
    ImageView img = new ImageView(getContext());
    img.setBackgroundResource(mDividerRes);
    return img;
}

From source file:at.alladin.rmbt.android.map.overlay.RMBTBalloonOverlayView.java

public void setBalloonData(final RMBTBalloonOverlayItem item, final ViewGroup parent) {
    // map our custom item data to fields
    //        title.setText(item.getTitle());
    resultItems = item.getResultItems();

    resultListView.removeAllViews();/*from   w w w  .  j  a  va 2  s  .  c o  m*/

    final float scale = getResources().getDisplayMetrics().density;

    final int leftRightItem = Helperfunctions.dpToPx(5, scale);
    final int topBottomItem = Helperfunctions.dpToPx(3, scale);

    final int leftRightDiv = Helperfunctions.dpToPx(0, scale);
    final int topBottomDiv = Helperfunctions.dpToPx(0, scale);
    final int heightDiv = Helperfunctions.dpToPx(1, scale);

    final int topBottomImg = Helperfunctions.dpToPx(1, scale);

    if (resultItems != null && resultItems.length() > 0) {

        for (int i = 0; i < 1; i++)
            // JSONObject resultListItem;
            try {
                final JSONObject result = resultItems.getJSONObject(i);

                final LayoutInflater resultInflater = (LayoutInflater) context
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

                final View resultView = resultInflater.inflate(R.layout.balloon_overlay_listitem, parent);

                final LinearLayout measurementLayout = (LinearLayout) resultView
                        .findViewById(R.id.resultMeasurementList);
                measurementLayout.setVisibility(View.GONE);

                final LinearLayout netLayout = (LinearLayout) resultView.findViewById(R.id.resultNetList);
                netLayout.setVisibility(View.GONE);

                final TextView measurementHeader = (TextView) resultView.findViewById(R.id.resultMeasurement);
                measurementHeader.setVisibility(View.GONE);

                final TextView netHeader = (TextView) resultView.findViewById(R.id.resultNet);
                netHeader.setVisibility(View.GONE);

                final TextView dateHeader = (TextView) resultView.findViewById(R.id.resultDate);
                dateHeader.setVisibility(View.GONE);

                dateHeader.setText(result.optString("time_string"));

                final JSONArray measurementArray = result.getJSONArray("measurement");

                final JSONArray netArray = result.getJSONArray("net");

                for (int j = 0; j < measurementArray.length(); j++) {

                    final JSONObject singleItem = measurementArray.getJSONObject(j);

                    final LinearLayout measurememtItemLayout = new LinearLayout(context); // (LinearLayout)measurememtItemView.findViewById(R.id.measurement_item);

                    measurememtItemLayout.setLayoutParams(
                            new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT,
                                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT));

                    measurememtItemLayout.setGravity(Gravity.CENTER_VERTICAL);
                    measurememtItemLayout.setPadding(leftRightItem, topBottomItem, leftRightItem,
                            topBottomItem);

                    final TextView itemTitle = new TextView(context, null, R.style.balloonResultItemTitle);
                    itemTitle.setLayoutParams(
                            new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 0.4f));
                    itemTitle.setTextAppearance(context, R.style.balloonResultItemTitle);
                    itemTitle.setWidth(0);
                    itemTitle.setGravity(Gravity.LEFT);
                    itemTitle.setText(singleItem.getString("title"));

                    measurememtItemLayout.addView(itemTitle);

                    final ImageView itemClassification = new ImageView(context);
                    itemClassification.setLayoutParams(
                            new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                                    android.view.ViewGroup.LayoutParams.MATCH_PARENT, 0.1f));
                    itemClassification.setPadding(0, topBottomImg, 0, topBottomImg);
                    // itemClassification.set setGravity(Gravity.LEFT);

                    itemClassification.setImageDrawable(getResources().getDrawable(
                            Helperfunctions.getClassificationImage(singleItem.getInt("classification"))));

                    measurememtItemLayout.addView(itemClassification);

                    final TextView itemValue = new TextView(context, null, R.style.balloonResultItemValue);
                    itemValue.setLayoutParams(
                            new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 0.5f));
                    itemValue.setTextAppearance(context, R.style.balloonResultItemValue);
                    itemValue.setWidth(0);
                    itemValue.setGravity(Gravity.LEFT);
                    itemValue.setText(singleItem.getString("value"));

                    measurememtItemLayout.addView(itemValue);

                    measurementLayout.addView(measurememtItemLayout);

                    final View divider = new View(context);
                    divider.setLayoutParams(new LinearLayout.LayoutParams(
                            android.view.ViewGroup.LayoutParams.MATCH_PARENT, heightDiv, 1));
                    divider.setPadding(leftRightDiv, topBottomDiv, leftRightDiv, topBottomDiv);

                    divider.setBackgroundResource(R.drawable.bg_trans_light_10);

                    measurementLayout.addView(divider);

                    measurementLayout.invalidate();
                }

                for (int j = 0; j < netArray.length(); j++) {

                    final JSONObject singleItem = netArray.getJSONObject(j);

                    final LinearLayout netItemLayout = new LinearLayout(context); // (LinearLayout)measurememtItemView.findViewById(R.id.measurement_item);

                    netItemLayout.setLayoutParams(
                            new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT,
                                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
                    netItemLayout.setPadding(leftRightItem, topBottomItem, leftRightItem, topBottomItem);

                    netItemLayout.setGravity(Gravity.CENTER_VERTICAL);

                    final TextView itemTitle = new TextView(context, null, R.style.balloonResultItemTitle);
                    itemTitle.setLayoutParams(
                            new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 0.4f));
                    itemTitle.setTextAppearance(context, R.style.balloonResultItemTitle);
                    itemTitle.setWidth(0);
                    itemTitle.setGravity(Gravity.LEFT);
                    itemTitle.setText(singleItem.getString("title"));

                    netItemLayout.addView(itemTitle);

                    final ImageView itemClassification = new ImageView(context);
                    itemClassification.setLayoutParams(
                            new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                                    android.view.ViewGroup.LayoutParams.MATCH_PARENT, 0.1f));
                    itemClassification.setPadding(0, topBottomImg, 0, topBottomImg);

                    itemClassification.setImageDrawable(
                            context.getResources().getDrawable(R.drawable.traffic_lights_none));
                    netItemLayout.addView(itemClassification);

                    final TextView itemValue = new TextView(context, null, R.style.balloonResultItemValue);
                    itemValue.setLayoutParams(
                            new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 0.5f));
                    itemValue.setTextAppearance(context, R.style.balloonResultItemValue);
                    itemValue.setWidth(0);
                    itemValue.setGravity(Gravity.LEFT);
                    itemValue.setText(singleItem.optString("value", null));

                    netItemLayout.addView(itemValue);

                    netLayout.addView(netItemLayout);

                    final View divider = new View(context);
                    divider.setLayoutParams(new LinearLayout.LayoutParams(
                            android.view.ViewGroup.LayoutParams.MATCH_PARENT, heightDiv, 1));
                    divider.setPadding(leftRightDiv, topBottomDiv, leftRightDiv, topBottomDiv);

                    divider.setBackgroundResource(R.drawable.bg_trans_light_10);

                    netLayout.addView(divider);

                    netLayout.invalidate();
                }

                measurementHeader.setVisibility(View.VISIBLE);
                netHeader.setVisibility(View.VISIBLE);

                measurementLayout.setVisibility(View.VISIBLE);
                netLayout.setVisibility(View.VISIBLE);

                dateHeader.setVisibility(View.VISIBLE);

                resultListView.addView(resultView);

                Log.d(DEBUG_TAG, "View Added");
                // codeText.setText(resultListItem.getString("sync_code"));

            } catch (final JSONException e) {
                e.printStackTrace();
            }

        progessBar.setVisibility(View.GONE);
        emptyView.setVisibility(View.GONE);

        resultListView.setVisibility(View.VISIBLE);

        resultListView.invalidate();
    } else {
        Log.i(DEBUG_TAG, "LEERE LISTE");
        progessBar.setVisibility(View.GONE);
        emptyView.setVisibility(View.VISIBLE);
        emptyView.setText(context.getString(R.string.error_no_data));
        emptyView.invalidate();
    }
}

From source file:com.myhexaville.iconanimations.gooey_fab.GooeyFabCompatImpl.java

private void addIcon() {
    mIcon = new ImageView(getContext());
    LayoutParams params = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    if (mIsLargeFab) {
        params.gravity = BOTTOM | CENTER_HORIZONTAL;
        params.bottomMargin = dpToPixels(16);
    } else {//from w  ww  .  jav  a2  s.co m
        params.gravity = CENTER;

    }
    mIcon.setLayoutParams(params);
    addView(mIcon);
}

From source file:com.bangqu.eshow.view.sliding.ESSlidingPlayView.java

/**
 * .//  www . ja  v  a 2 s  .com
 */
public void creatIndex() {
    //?
    navLinearLayout.removeAllViews();
    mNavLayoutParent.setHorizontalGravity(navHorizontalGravity);
    navLinearLayout.setGravity(Gravity.CENTER);
    navLinearLayout.setVisibility(View.VISIBLE);
    count = mListViews.size();
    navLayoutParams.setMargins(5, 5, 5, 5);
    navLayoutParams.width = 15;
    navLayoutParams.height = 15;
    for (int j = 0; j < count; j++) {
        ImageView imageView = new ImageView(context);
        imageView.setLayoutParams(navLayoutParams);
        if (j == 0) {
            imageView.setImageDrawable(displayDrawable);
        } else {
            imageView.setImageDrawable(hideDrawable);
        }
        ESViewUtil.scaleView(imageView);
        navLinearLayout.addView(imageView, j);
    }

}

From source file:cn.org.eshow.framwork.view.sliding.AbSlidingPlayView.java

/**
 * ./*from  ww w  .  j a  va2 s. com*/
 */
public void creatIndex() {
    //?
    navLinearLayout.removeAllViews();
    mNavLayoutParent.setHorizontalGravity(navHorizontalGravity);
    navLinearLayout.setGravity(Gravity.CENTER);
    navLinearLayout.setVisibility(View.VISIBLE);
    count = mListViews.size();
    navLayoutParams.setMargins(5, 5, 5, 5);
    navLayoutParams.width = 15;
    navLayoutParams.height = 15;
    for (int j = 0; j < count; j++) {
        ImageView imageView = new ImageView(context);
        imageView.setLayoutParams(navLayoutParams);
        if (j == 0) {
            imageView.setImageDrawable(displayDrawable);
        } else {
            imageView.setImageDrawable(hideDrawable);
        }
        AbViewUtil.scaleView(imageView);
        navLinearLayout.addView(imageView, j);
    }

}

From source file:edu.ptu.navpattern.tooltip.Tooltip.java

private View getContentView(final Builder builder) {
    GradientDrawable drawable = new GradientDrawable();
    drawable.setColor(builder.mBackgroundColor);
    drawable.setCornerRadius(builder.mCornerRadius);
    LinearLayout vgContent = new LinearLayout(builder.mContext);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        vgContent.setBackground(drawable);
    } else {/*  w ww  . j a v  a  2 s  .c  om*/
        //noinspection deprecation
        vgContent.setBackgroundDrawable(drawable);
    }
    int padding = (int) builder.mPadding;
    vgContent.setPadding(padding, padding, padding, padding);
    vgContent.setOrientation(LinearLayout.VERTICAL);
    LinearLayout.LayoutParams textViewParams = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0);
    textViewParams.gravity = Gravity.CENTER;
    textViewParams.topMargin = 1;
    vgContent.setLayoutParams(textViewParams);
    vgContent.setDividerDrawable(vgContent.getResources().getDrawable(R.drawable.divider_line));
    vgContent.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);

    if (builder.itemText != null && builder.itemText.length > 0) {
        for (int i = 0; i < builder.itemText.length; i++) {

            TextView textView = new TextView(builder.mContext);
            textView.setText(builder.itemText[i]);
            textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 44);
            textView.setTextColor(0xffffffff);
            textView.setGravity(Gravity.CENTER_VERTICAL);
            if (builder.itemLogo != null && builder.itemLogo.length > i) {
                Drawable drawableLeft = builder.mContext.getResources().getDrawable(builder.itemLogo[i]);
                /// ??,??.
                //                    drawableLeft.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
                //                    textView.setCompoundDrawables(drawableLeft, null, null, null);
                //                    textView.setCompoundDrawablePadding(4);
                //                    textView.setBackgroundDrawable(drawableLeft);
                LinearLayout linearLayout = new LinearLayout(builder.mContext);
                linearLayout.setMinimumHeight((int) dpToPx(44f));
                linearLayout.setOrientation(LinearLayout.HORIZONTAL);
                linearLayout.setGravity(Gravity.CENTER_VERTICAL);
                ImageView icon = new ImageView(builder.mContext);
                icon.setImageDrawable(drawableLeft);
                linearLayout.addView(icon);
                linearLayout.addView(textView);
                vgContent.addView(linearLayout);
                final int position = i;
                linearLayout.setClickable(false);
                linearLayout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (builder.mOnItemClickListener != null) {
                            builder.mOnItemClickListener.onClick(position);
                        }
                        mTouchListener.onTouch(v,
                                MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(),
                                        MotionEvent.ACTION_UP, v.getLeft() + 5, v.getTop() + 5, 0));
                    }
                });
            } else {
                vgContent.addView(textView);
                final int position = i;
                textView.setClickable(false);
                textView.setMinimumHeight((int) dpToPx(44f));
                textView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (builder.mOnItemClickListener != null) {
                            builder.mOnItemClickListener.onClick(position);
                        }
                        mTouchListener.onTouch(v, null);
                    }
                });
            }
        }

    }

    mArrowView = new ImageView(builder.mContext);
    mArrowView.setImageDrawable(builder.mArrowDrawable);

    LinearLayout.LayoutParams arrowLayoutParams;
    if (mGravity == Gravity.TOP || mGravity == Gravity.BOTTOM) {
        arrowLayoutParams = new LinearLayout.LayoutParams((int) builder.mArrowWidth, (int) builder.mArrowHeight,
                0);
    } else {
        arrowLayoutParams = new LinearLayout.LayoutParams((int) builder.mArrowHeight, (int) builder.mArrowWidth,
                0);
    }
    arrowLayoutParams.gravity = Gravity.CENTER;
    mArrowView.setLayoutParams(arrowLayoutParams);

    mContentView = new LinearLayout(builder.mContext);
    mContentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    mContentView.setOrientation(mGravity == Gravity.START || mGravity == Gravity.END ? LinearLayout.HORIZONTAL
            : LinearLayout.VERTICAL);

    padding = (int) dpToPx(5);

    switch (mGravity) {
    case Gravity.START:
        mContentView.setPadding(0, 0, padding, 0);
        break;
    case Gravity.TOP:
    case Gravity.BOTTOM:
        mContentView.setPadding(padding, 0, padding, 0);
        break;
    case Gravity.END:
        mContentView.setPadding(padding, 0, 0, 0);
        break;
    }

    if (mGravity == Gravity.TOP || mGravity == Gravity.START) {
        mContentView.addView(vgContent);
        mContentView.addView(mArrowView);
    } else {
        mContentView.addView(mArrowView);
        mContentView.addView(vgContent);
    }

    if (builder.isCancelable || builder.isDismissOnClick) {
        mContentView.setOnTouchListener(mTouchListener);
    }
    return mContentView;
}