0

I am a beginner to android development and I am trying to make something like this in my application.

enter image description here

I found a great question and an answer related to my issue here Android - How to display a dialog over a native screen?. But, it didn't work as expected. May be I am doing something wrong.

I am attaching the code that I am using to achieve this. Any help would be highly appreciated and if any one can guide me in the right direction that I can follow.

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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="com.example.myapp.MainActivity">

</android.support.constraint.ConstraintLayout>

style.xml

<resources>

    <!-- Base application theme. -->
    <style name="myTheme" parent="android:style/Theme.Dialog">
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:backgroundDimEnabled">true</item>
        <item name="android:background">@android:color/transparent</item>
    </style>

</resources>

MainActivity.java

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        AlertDialog LDialog = new AlertDialog.Builder(getApplicationContext())
            .setTitle("Call Blocked")
            .setMessage("Call Blocked, reroute call?")
            .setPositiveButton("ok", null).create();
        LDialog.show();

    }
}

AndroidManifest.xml

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:launchMode="singleInstance" android:excludeFromRecents="true"
    android:taskAffinity="" android:theme="@android:style/Theme.Dialog">
...............
...............
</application>

Here, what I am getting now.

enter image description here

Harshana
  • 524
  • 3
  • 16

1 Answers1

0

Answering the own question because I found the concept that I need to use. It is FAB or Floating Action Button as described here https://developer.android.com/guide/topics/ui/floating-action-button. Also, facebook uses the same concept with the name facebook chat heads.

Harshana
  • 524
  • 3
  • 16