I am trying to create custom dialog
Base Layout(I have also tried various modified layouts)
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@color/dialogHeaderBackground"
android:gravity="center"
android:minHeight="@dimen/minHeightDialogTitle"
android:text=""
android:textStyle="bold" />
<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/title"
android:layout_marginTop="5dp"
android:text="" />
<LinearLayout
android:id="@+id/loutButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/message"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<Button
android:id="@+id/btnNeutral"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" />
<Button
android:id="@+id/btnNegative"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" />
<Button
android:id="@+id/btnPositive"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" />
</LinearLayout>
</RelativeLayout>
Java Code
Dialog dialog = new Dialog(this);
// Dialog dialog = new Dialog(this,R.style.Theme_Dialog);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.custom_dialog);
Button btnPositive=(Button) dialog.findViewById(R.id.btnPositive);
Button btnNegative=(Button) dialog.findViewById(R.id.btnNegative);
Button btnNeutral=(Button) dialog.findViewById(R.id.btnNeutral);
TextView txvTitle=(TextView)dialog.findViewById(R.id.title);
TextView txvMessage=(TextView)dialog.findViewById(R.id.message);
...
so on and so forth
I get following dialog, which is fullscreen, WHICH I DO NOT WANT
Solutions Already Tried, which give same results as above screenshot
- Styles.xml configuration 1 | Implemented Pastebin code
- Styles.xml configuration 2 | Implemented Pastebin code
- The example provided in Android Dev Guide using AlertDialog.Builder | Implemented Java Code
- None of my underlying layout use
MATCH_PARENT
in height. As said in this Stack overflow answer - Also try to change window settings to
WRAP_CONTENT
for dialog based on answer here | Implemented Java Code in Pastebin - Have also tried to keep entire
RelativeLayout
inside a parentLinearLayout
, see the 3rd comment in following answer
The only time I can get decent dialog is when specifying height for the xml layout, like this android:layout_height="150dp"
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="150dp" >
Dialog when fixed height is specified,
- The content/layout goes missing when message is bigger
- When message is smaller, dialog is displayed bigger than required, see below OK button
Don't suggest the above(specify fixed height) as solution as it is not efficient and not looking that good and also not dynamic, its static
Question
What to do specify,decent looking custom dialog which is customizable too?
I am willing to give bounty as a token of appreciation if you can help me solve this issue
EDIT: Provided bounty to correct solution.