Example usage for android.widget PopupWindow getHeight

List of usage examples for android.widget PopupWindow getHeight

Introduction

In this page you can find the example usage for android.widget PopupWindow getHeight.

Prototype

public int getHeight() 

Source Link

Document

Returns the popup's requested height.

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);// w  ww. java2 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());

}

From source file:cc.echonet.coolmicapp.MainActivity.java

private void goAbout() {

    Log.d("MainActivity", "goAbout() ");

    LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View popUpView = inflater.inflate(R.layout.popup_about, null, false);

    final PopupWindow popUp = new PopupWindow(this);

    Button close = (Button) popUpView.findViewById(R.id.cmdPopUpDismiss);
    close.setOnClickListener(new View.OnClickListener() {
        public void onClick(View popupView) {
            popUp.dismiss();//w  w w.  ja v a2s  . co  m
        }
    });

    ((TextView) popUpView.findViewById(R.id.txtVersion)).setText(BuildConfig.VERSION_NAME);
    ((TextView) popUpView.findViewById(R.id.txtBuildType)).setText(BuildConfig.BUILD_TYPE);
    ((TextView) popUpView.findViewById(R.id.txtGITBranch)).setText(BuildConfig.GIT_BRANCH);
    ((TextView) popUpView.findViewById(R.id.txtGITRevision)).setText(BuildConfig.GIT_REVISION);
    ((TextView) popUpView.findViewById(R.id.txtGITAuthor)).setText(BuildConfig.GIT_AUTHOR);
    ((TextView) popUpView.findViewById(R.id.txtGITDirty)).setText(BuildConfig.GIT_DIRTY);

    popUpView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);

    popUp.setContentView(popUpView);

    Log.d("MainActivity", String.format("h: %s w: %s h: %s w: %s", popUp.getHeight(), popUp.getWidth(),
            popUpView.getMeasuredHeight(), popUpView.getMeasuredWidth()));

    popUp.setHeight(popUpView.getMeasuredHeight());
    popUp.setWidth(popUpView.getMeasuredWidth());

    popUp.showAtLocation(popUpView, Gravity.CENTER, 0, 0);

    Log.d("MainActivity", "goAbout() end ");
}