Example usage for android.widget HorizontalScrollView measure

List of usage examples for android.widget HorizontalScrollView measure

Introduction

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

Prototype

public final void measure(int widthMeasureSpec, int heightMeasureSpec) 

Source Link

Document

This is called to find out how big a view should be.

Usage

From source file:org.zywx.wbpalmstar.plugin.uexscrawl.PhotoScrawlActivity.java

private void showColorChoosePop() {
    LinearLayout linearLayout = new LinearLayout(this);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    int margin = EUExUtil.dipToPixels(8);
    lp.setMargins(margin / 2, margin, margin / 2, margin);
    linearLayout.setLayoutParams(lp);/*from   ww w. j  a  v a2 s  .c  o  m*/
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    for (int color : colors) {
        linearLayout.addView(getColorImageView(color));
    }
    HorizontalScrollView scrollView = new HorizontalScrollView(this);
    LinearLayout.LayoutParams scrollLp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    scrollView.setLayoutParams(scrollLp);
    scrollView.addView(linearLayout);

    int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    scrollView.measure(w, h);
    PopupWindow popupWindow = new PopupWindow(scrollView);
    popupWindow.setBackgroundDrawable(new ColorDrawable());
    popupWindow.setFocusable(true);
    popupWindow.setOutsideTouchable(true);
    popupWindow.setWidth(mImageContentLayout.getWidth());
    popupWindow.setHeight(scrollView.getMeasuredHeight());
    popupWindow.showAtLocation(mImageContentLayout, Gravity.BOTTOM, 0,
            mCloseLayout.getHeight() + mBrushLayout.getHeight() + popupWindow.getHeight());

}