Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Custom Dialog stretches across screen instead of wrapping content
    primarykey
    data
    text
    <p>I'm trying to make a custom dialog, and for some reason it stretches out horizontally across the entire screen even though i set it's width to wrap_content...</p> <p>Here is the XML file:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt; &lt;Button android:id="@+id/btnContinue" android:layout_marginRight="10dp" android:layout_marginTop="60px" android:layout_alignParentRight="true" android:background="@drawable/btn_dialog_continue" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;Button android:id="@+id/btnCancel" android:layout_alignTop="@+id/btnContinue" android:layout_toLeftOf="@id/btnContinue" android:background="@drawable/btn_dialog_cancel" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;EditText android:id="@+id/input" android:layout_width="wrap_content" android:layout_marginBottom="4dp" android:layout_alignLeft="@id/btnCancel" android:background="@drawable/bg_text_round" android:layout_alignParentRight="true" android:layout_height="56px" android:layout_marginRight="15px" /&gt; &lt;ImageView android:id="@+id/thumb" android:layout_width="136px" android:layout_toLeftOf="@id/input" android:layout_height="105px" android:paddingLeft="18px" android:paddingTop="20px" android:paddingRight="20px" android:paddingBottom="18px" android:layout_centerVertical="true" android:background="@drawable/bg_tagrow_item" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>And the java code:</p> <pre><code> final Dialog dialog = new Dialog(this, R.style.TextDialog); dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON); dialog.setContentView(R.layout.text_dialog); dialog.setTitle(titleId); ImageView thumb = (ImageView) dialog.findViewById(R.id.thumb); Button btnContinue = (Button) dialog.findViewById(R.id.btnContinue); Button btnCancel = (Button) dialog.findViewById(R.id.btnCancel); final EditText input = (EditText) dialog.findViewById(R.id.input); thumb.setImageBitmap(mTagAdapter.mCollection.mThumbCache[mTagAdapter.mCollection.names .indexOf(getTargets()[0])]); dialog.show(); dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.ic_dialog_menu_generic); </code></pre> <p>Thanks</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.
    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