Android dialog width Android dialog width android android

Android dialog width


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="match_parent"    android:layout_height="match_parent">    contents here</LinearLayout>


I'm using:

getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);


Set a minimum width at the top most layout.

android:minWidth="300dp"

For example:

<?xml version="1.0" encoding="utf-8"?><LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"  xmlns:android="http://schemas.android.com/apk/res/android" android:minWidth="300dp"><!-- Put remaining contents here --></LinearLayout>