2

I am currently trying to add a detail view feature for some elements of my app, and I am looking to display them like this dialog box in the Chrome app:

(It opens when you click on the https lock symbol) Chrome pop-up

The box should cover the entire top of the apps window and not leave space on top, right or left, just on the bottom of course. It also should be dismissable by clicking outside of it.

I was trying to do this for a while now but without success.

How can I achieve this?

fusionlightcat
  • 365
  • 1
  • 5
  • 20
  • https://stackoverflow.com/questions/9467026/changing-position-of-the-dialog-on-screen-android – IntelliJ Amiya Aug 01 '17 at 08:11
  • 1
    there is nothing special in this dialog. Show what `I was trying to do this for a while`, and we'll try to help. – Vladyslav Matviienko Aug 01 '17 at 08:14
  • I basically tried to do it with a Activity but figured that it was too slow and I also managed to screw up the transparency, so nothing to show you really. I was looking for a whole other way. :) @Vlad – fusionlightcat Aug 01 '17 at 09:47

2 Answers2

2

You can achieve it in several ways.

First one

Create your own analogue of DialogFragment (don't extend existing one) with your view (which'll be placed in the top) and show it like this:

getSupportFragmentManager().beginTransaction()
        .add(new MyDialogFragment(), android.R.id.content)
        .commit();

android.R.id.content is like root view of your activity (setContentView() adds view on top of it).

Activity one

You can create Activity that will be transparent and 'll have this "card" on the top.

Third one

Just make Dialog appear at the top of screen. Like this.

Ekalips
  • 1,473
  • 11
  • 20
  • 1
    @fusionlightcat just don't forget to remove any fragment reference `onDestroy()` to avoid memory leak ;) –  Ekalips Aug 01 '17 at 10:40
0

No sure if this is what you need but have a look at this library.

https://github.com/Tapadoo/Alerter

Ragesh Ramesh
  • 3,470
  • 2
  • 14
  • 20