0

How to create a popup view in android? Context menu shows only a list of items. But I'm trying to show a custom layout instead. I searched the internet but found nothing. May be I can't express what I'm trying to do!

I've a Bottom Bar in my app. Which have some buttons in it. I want that when I click a specific button a popup will be shown near that view. Just like context menu but with different layout. Is it possible?

I want something Like this.

Like this one

ADM
  • 20,406
  • 11
  • 52
  • 83
  • 1
    Have you tried using [PopUpWindow](https://stackoverflow.com/questions/5944987/how-to-create-a-popup-window-popupwindow-in-android)? – ADM Jul 11 '21 at 11:09
  • Something like this isn't exactly a popup, it's just a custom view that shows on top of the view when you make it visible – Ahmad Sattout Jul 11 '21 at 11:15

1 Answers1

0

You can do something like this

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:background="@color/black">


    </LinearLayout>

    <androidx.recyclerview.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="40dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        android:background="@color/white"/>

</androidx.constraintlayout.widget.ConstraintLayout>

enter image description here

The main idea is the last item overlaps the previous item. You just have to implement the recycler view and set its direction left to right. You can also enable and disable visibility like normal view.

Eishon
  • 1,274
  • 1
  • 9
  • 17