Example usage for android.widget PopupWindow getWidth

List of usage examples for android.widget PopupWindow getWidth

Introduction

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

Prototype

public int getWidth() 

Source Link

Document

Returns the popup's requested width.

Usage

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();//from ww  w. j  ava 2s.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 ");
}