PopupWindow overlaps ActionBar

android popupwindow
custom popup window android
android popup window show at location
popup window in fragment android
popupwindow showatlocation
android popup window animation
android popup window programmatically
popup window with listview android example

I am using PopupWindow for show validation error with showAsDropDown(anchor).Validation Fields are validated by pressing the save button, so If anchor place under action bar, its popup overlaps actionBar. How do I fix this?

 protected void showPopup(View anchorPlace) {
    popupContainer.removeAllViews();
    popupContainer.addView(recyclerErrors);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        popupContainer.setElevation(0);
        anchorPlace.setElevation(0);
        popup.setElevation(0);
    }
    recyclerErrors.setOnClickListener(v -> dismissPopup());
    popup.setContentView(popupContainer);
    if (anchorPlace != null) {
        popup.setWidth(anchorPlace.getWidth());
    }
    popup.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
    popup.setOutsideTouchable(true);
    popup.setFocusable(false);
    popup.setTouchable(true);
    popup.setBackgroundDrawable(null);

    if (anchorPlace != null) {
        PopupWindowCompat.showAsDropDown(popup, anchorPlace, 0, 0, Gravity.BOTTOM);
    }

    if (popup.isAboveAnchor()) {
        popup.dismiss();
    }
}

Popup for validation error XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="20dp"
    app:srcCompat="@drawable/warning_triangle" />

<TextView
    android:id="@+id/error_field_error_txt"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/warning_bcg"
    android:drawableStart="@drawable/ic_warning"
    android:drawablePadding="@dimen/settings_error_body_padding_top_bottom"
    android:gravity="center_vertical"
    android:paddingStart="@dimen/settings_error_body_padding_start_end"
    android:paddingTop="@dimen/settings_error_body_padding_top_bottom"
    android:paddingEnd="@dimen/settings_error_body_padding_start_end"
    android:paddingBottom="@dimen/settings_error_body_padding_top_bottom"
    android:textColor="@android:color/white"
    android:textSize="@dimen/settings_error_text_size"
    android:textStyle="bold"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"/></LinearLayout>

Try calling editText.requestFocus() before calling showPopup(...) and do let me know if it worked.

PopupWindow overlaps ActionBar, PopupWindow overlaps ActionBar. I am using PopupWindow for show validation error with showAsDropDown(anchor).Validation Fields are� I am working with Actionbar in android. In my layout the Actionbar appears correctly. But my fragment's layout overlaps with Actionbar. See the below image. And my layout file is below.

Try popup.setAttachedInDecor(true)

This will attach the popup window to the decor frame of the parent window to avoid overlaping with screen decorations like the navigation bar.

Also you may try using popup.setOverlapAnchor(false)

Sets whether the popup window should overlap its anchor view when displayed as a drop-down.

Hope it helps.

PopupWindow, Returns whether the popup window should overlap its anchor view when displayed as a drop-down. Parameters. popupWindow, PopupWindow� On pre-Lollipop devices, this popup looks fine, but on Android 5.0, the popup overlaps the soft buttons: Here's the PopupWindow on an Android 4.4 device: Does anyone have an idea why this happens and how this can be fixed? Answer:

try to subtract both action and status bar height :

popup.setHeight(WindowManager.LayoutParams.WRAP_CONTENT - actionBarHeight - statusBarHeight);

my case, i created popupwindow programmatically with a FrameLayout parent.

PopupWindow popupWindow = new PopupWindow(frameLayout, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT - actionBarHeight - statusBarHeight);

PopupWindowCompat, I would like for this menu to also overlap the actionbar, when the menu is visible. popupwindow and also you can specify an ANCHOR in your case it would be� ActionBar pattern is widely used since Honeycomb released. As the action bar actually take space of your limited screen, you may need make the action bar semi-transparent to save some space. ActionBar API provide an method to overlay your action bar on your screen content. as the training material mentioned:

Try these !

1st hide keyboard, so the top content will be visible.

public void hideSoftKeyboard(View view){
  InputMethodManager imm =(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
  imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

Then if you are using scrollview scroll to where (EditText/Other View) you want to show popup !

View targetView = findViewById(R.id.DESIRED_VIEW_ID);  
targetView.getParent().requestChildFocus(targetView,targetView);

Ref: https://stackoverflow.com/a/31764551/5557479

or another ref : https://stackoverflow.com/a/35627860/5557479

Is it possible in Android to create a view that overlaps the actionbar , the PopupWindow overlaps with the ActionBar (and under the status bar, and not overlap the ActionBar, or (2) get the PopupWindow to update its position in� Tech support scams are an industry-wide issue where scammers trick you into paying for unnecessary technical support services. You can help protect yourself from scammers by verifying that the contact is a Microsoft Agent or Microsoft Employee and that the phone number is an official Microsoft global customer service number.

Android PopupWindow not changing position after calling update , Custom item state list drawable background for action bar items. --> Default PopupWindow style. Whether the popup window should overlap its anchor view. The command in onLoad is run when the document is finished loading. Like in our previous example, the command runs popup(), but this time the first argument for popup() is a little different.

sdk/extras/android/support/v7/appcompat/res/values/attrs.xml , I'm trying to create a dialog popup window with a custom layout, but my Currently my popup is overlapping other views. PopupWindow overlaps ActionBar. A window that suddenly appears (pops up) when you select an option with a mouse or press a special function key. Usually, the pop-up window contains a menu of commands and stays on the screen only until you select one of the commands. It then disappears. A special kind of pop-up window is a pull

Android - 绵阳斯懿新材料科技有限公司, Merge "Make overlapAnchor public, make ActionBar spinner overlap" Whether the popup window should overlap its anchor view. -->. Questions: I want to close a PopupWindow by either tapping outside the window or pressing a back button. Right now you can tap anywhere on the screen and the window closes, and I can’t figure out why. I’d also like to add a shadow to the PopupWindow. Thanks! MainActivity.Java: public class MainActivity extends FragmentActivity implements

Comments
  • Please add the xml code
  • ActionBar isn't overlapping content. But popup with text "The attribute must be valid.." is overlapping all.
  • this case will not solve the problem if a navigation drawer is open
  • There are a lot of edittexts on the screen, so hiding the keyboard won't solve this problem
  • Then 1st scroll to where to view popup then display popup !