Wrong custom-dialog size



I got a problem with a custom dialog in an android application.


I got a Custom Dialog with a ListView inside it. The Dialog itself is 600dp width and the ListView is 600dp as well.


The problem is that the dialog is more than that width value:


http://ift.tt/16IoiWW


http://ift.tt/1AWYejQ [Same image with the "Show layout limits" option enabled]


This is the Dialog layout:



<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="600dp"
android:layout_height="wrap_content"
android:orientation="vertical">

<ListView
android:id="@+id/promotionListView"
android:layout_width="600dp"
android:layout_height="400dp"
android:scrollbarStyle="insideOverlay"
android:dividerHeight="1dp" />

<LinearLayout
android:layout_width="600dp"
android:layout_height="wrap_content"
android:orientation="horizontal">

<Button
android:id="@+id/promotion_dialog_abort"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/annulla"/>

<Button
android:id="@+id/promotion_dialog_apply"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/applica"/>

</LinearLayout>
</LinearLayout>


This is the layout of the single row: (note that both the width of the layout and the sum of single views is 600dp)



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:orientation="horizontal"
android:layout_width="600dp" <-- I tried "wrap_content" and "match_parent" with the same result
android:layout_height="wrap_content">

<CheckBox
android:id="@+id/promotionCheck"
android:layout_width="50dp"
android:layout_height="50dp"
android:gravity="center"
android:layout_gravity="center" />

<TextView
android:id="@+id/promotionText"
android:layout_width="350dp"
android:layout_height="50dp"
android:gravity="center_vertical"
android:layout_gravity="center"
android:textColor="@android:color/white"
android:textSize="@dimen/customerdetail_headertextsize" />

<TextView
android:id="@+id/promotionFactor"
android:layout_width="100dp"
android:layout_height="50dp"
android:gravity="center_vertical|right"
android:layout_gravity="center"
android:textColor="@android:color/white"
android:textSize="@dimen/customerdetail_headertextsize" />

<TextView
android:id="@+id/promotionPrice"
android:layout_width="100dp"
android:layout_height="50dp"
android:gravity="center_vertical|right"
android:layout_gravity="center"
android:textColor="@android:color/white"
android:textSize="@dimen/customerdetail_headertextsize" />

</LinearLayout>


And finally the Custom Dialog Class



public class PromotionDialog extends Dialog {

private boolean authCode;
private Set<OrderDetailDiscount> promotions;
private List<OrderDetailDiscount> selectedPromotions;

private ListView mainListView;

public Response response = Response.CANCEL;

private Button buttonAbort;
private Button buttonAccept;

public PromotionDialog(Context context, boolean authCode, Set<OrderDetailDiscount> promotions) {
super(context);

this.authCode = authCode;
this.promotions = promotions;

selectedPromotions = new ArrayList<>();

setTitle("Promozioni");
setContentView(R.layout.isfa_promotiondialog);

buttonAbort = (Button) findViewById(R.id.promotion_dialog_abort);
buttonAccept = (Button) findViewById(R.id.promotion_dialog_apply);
}

}


I really can't understand what the problem is, I tried to manually resize the titlebar with no success... what could I possibbly try?


No comments:

Post a Comment