Calling android dialog without it fading the background
Create a res/values/styles.xml file and add this to it.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.DoNotDim" parent="android:Theme">
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
And apply the theme to your activity.
<activity android:name=".SampleActivity" android:theme="@style/Theme.DoNotDim">
How to remove transparent dark background outside of dialog box
Your question has already been answered here
Code from the link:
Add this to your styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.DoNotDim" parent="android:Theme">
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
And then apply the theme to your activity:
<activity android:name=".SampleActivity" android:theme="@style/Theme.DoNotDim">
Custom dialog not showing, just faded black background
The issue is arising due to the fact that you are not giving it any style.
Use infoDialog.setView(view)
And while creating dialogbox give a material theme style
val infoDialog = AlertDialog.Builder(ContextThemeWrapper(context,android.R.style.ThemeOverlay_Material_Dialog)).create()
and in the end
infoDialog.window.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
infoDialog.show()
Rest of your code is fine.
Prevent Android activity dialog from closing on outside touch
This could help you. It is a way to handle the touch outside event:
How to cancel an Dialog themed like Activity when touched outside the window?
By catching the event and doing nothing, I think you can prevent the closing. But what is strange though, is that the default behavior of your activity dialog should be not to close itself when you touch outside.
(PS: the code uses WindowManager.LayoutParams)
Related Topics
Android Logcat Logs Chatty Module Line Expire Message
Setexactandallowwhileidle - Is Not Exact as of Developer Reference
Mediastore - Uri to Query All Types of Files (Media and Non-Media)
How to Change Viewpager's Page
Logcat Not Displaying My Log Calls
Dynamically Updating an Autocompletetextview Adapter
Adding Tab Inside Fragment in Android
How to Tell If a Closed Path Contains a Given Point
Assign Width to Half Available Screen Width Declaratively
Error:Unexpected Lock Protocol Found in Lock File. Expected 3, Found 0
Android Failed to Install Helloworld.Apk on Device (Null) Error
How to Read and Edit Android Calendar Events Using the New Android 4.0 Ice Cream Sandwich API
What Is the Benefit of Using Fragments in Android, Rather Than Views