views:

1071

answers:

2

I can't seem to control the dialog width. I have a simple layout like so`

<TextView android:id="@+id/name_prompt_view"
    android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:text="@string/name_prompt"
 android:padding="10dip"/>
<EditText android:id="@+id/name_inp" android:layout_width="fill_parent" 

android:layout_height="wrap_content" android:lines="1" android:maxLines="1" android:maxLength="48" android:inputType="text">

 </LinearLayout>

`

for some reason the dialog is only wide enough for the text input field about 11 chars wide. How do I make the dialog width fill the screen?

+1  A: 

i had the same problem.

i used following code to make dialog fill_parent and it worked fine.

public class SharePost extends Dialog 
{


@Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.adaptor_contentsharepost);

LayoutParams params = getWindow().getAttributes(); 
                params.height = LayoutParams.FILL_PARENT; 
                 getWindow().setAttributes((android.view.WindowManager.LayoutParams) params); 


}

}

layout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
   android:id="@+id/dialogWidth"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"

>

contents here

</LinearLayout>
UMMA
A: 

As Matthias points at out http://stackoverflow.com/questions/1362723/how-can-i-get-a-dialog-style-activity-window-to-fill-the-screen/1693716#1693716 UMMA's solution works, but only if the window attributes are set AFTER setContentView() is called.

Alex Pretzlav