Note that there are some explanatory texts on larger screens.

plurals
  1. POVery customized DialogFragment
    primarykey
    data
    text
    <p>I want to do the following (paint incoming):</p> <p><img src="https://i.stack.imgur.com/8By05.png" alt="enter image description here"></p> <p>As you can see, the dialog is in the middle of the screen, with a custom View.</p> <p>However, I want to user be able to click "behind" the dialog, and never dismiss the dialog.</p> <p>I did the following implementation (<code>DialogFragment</code>):</p> <pre><code>** * Triggered when the Dialog is created. * * @param savedInstanceState - Bundle containing saved information. * * @return Dialog ready to be shown. */ @Override public Dialog onCreateDialog( Bundle savedInstanceState ) { Dialog dialog = new Dialog( context ); setCancelable( false ); return dialog; } @Override public void onCreate( Bundle savedInstanceState ) { super.onCreate( savedInstanceState ); setStyle( STYLE_NO_INPUT, R.style.launcherDialog ); } </code></pre> <p>This is generating the following:</p> <p><img src="https://i.stack.imgur.com/5l2zP.png" alt="enter image description here"></p> <p>This is almost correct, now I want to do two things:</p> <ul> <li>Add custom View</li> <li>Remove the gray background generated from dialog.</li> </ul> <p>So to add a custom view, I did the following in <code>onCreateDialog</code>:</p> <pre><code>LayoutInflater inflater = LayoutInflater.from( context ) View progressbarLayout = inflater.inflate( R.layout.launcher_dialog_view, null ); dialog.setContentView( progressbarLayout ); </code></pre> <p>But I get this Exception:</p> <blockquote> <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{SearchActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content </code></pre> </blockquote> <p>And anyways, I still have missing how can I remove the gray background generated by the <code>DialogFragment</code>.</p> <p>Tips are soooo appreciated. I've been stuck on this for so many hours.</p> <p>Edit: Oh, and the layout is:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/launcher_ad_holder" android:layout_height="150dp" android:layout_width="150dp" android:background="@android:color/transparent"&gt; &lt;RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New RadioButton" android:id="@+id/radioButton" android:layout_centerVertical="true" android:layout_alignParentRight="true"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>And the styles:</p> <pre><code>&lt;resources&gt; &lt;style name="launcherDialog" parent="@android:style/Theme.Dialog"&gt; &lt;item name="android:windowFrame"&gt;@null&lt;/item&gt; &lt;item name="android:windowBackground"&gt;@android:color/transparent&lt;/item&gt; &lt;item name="android:windowIsFloating"&gt;false&lt;/item&gt; &lt;item name="android:windowContentOverlay"&gt;@null&lt;/item&gt; &lt;item name="android:windowTitleStyle"&gt;@null&lt;/item&gt; &lt;item name="android:colorBackgroundCacheHint"&gt;@null&lt;/item&gt; &lt;item name="android:windowAnimationStyle"&gt;@android:style/Animation.Dialog&lt;/item&gt; &lt;item name="android:windowSoftInputMode"&gt;stateUnspecified|adjustPan&lt;/item&gt; &lt;item name="android:gravity"&gt;bottom&lt;/item&gt; &lt;/style&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload