Я создал собственный диалог, который представляет собой простой калькулятор.У меня проблема с макетом в Android 2.3.3.Диалог оборачивает калькулятор идеально в 2.2.1 и ниже, но в 2.3.3 это не так.Ниже я разместил фотографию того, что происходит, и код XML для макета.И ниже это код того, как я запускаю диалог.Спасибо за помощь !!!
диалог в HTC Thunderbold 2.2.1 http://img20.imageshack.us/img20/6981/htc221.png
диалог в droidX 2.3.3 http://img64.imageshack.us/img64/876/droidx233.png
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="@+id/calc_dialog_display"
android:textSize="@dimen/calc_dialog_text_size"
android:editable="false"
android:clickable="false"
android:focusable="false"
android:cursorVisible="false"
android:gravity="right"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_width="238dp"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/calc_dialog_display_fake"
android:textSize="@dimen/calc_dialog_text_size"
android:visibility="invisible"
android:editable="false"
android:clickable="false"
android:focusable="false"
android:cursorVisible="false"
android:gravity="right"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_width="238dp"
android:layout_height="wrap_content" />
<Button
android:id="@+id/enter_total"
android:text="@string/calc_dialog_enter_total_button"
android:textSize="@dimen/calc_dialog_text_size"
android:layout_below="@id/calc_dialog_display"
android:layout_alignParentLeft="true"
android:layout_width="180dp"
android:layout_height="@dimen/calc_dialog_button_height" />
<Button
android:id="@+id/all_clear"
android:text="AC"
android:textSize="@dimen/calc_dialog_text_size"
android:textColor="@color/all_clear_color"
android:layout_below="@id/calc_dialog_display"
android:layout_toRightOf="@id/enter_total"
android:layout_width="@dimen/calc_dialog_button_width"
android:layout_height="@dimen/calc_dialog_button_height" />
<Button
android:id="@+id/seven"
android:text="7"
android:textSize="@dimen/calc_dialog_text_size"
android:layout_below="@id/enter_total"
android:layout_alignParentLeft="true"
android:layout_width="@dimen/calc_dialog_button_width"
android:layout_height="@dimen/calc_dialog_button_height" />
<Button
android:id="@+id/eight"
android:text="8"
android:textSize="@dimen/calc_dialog_text_size"
android:layout_below="@id/enter_total"
android:layout_toRightOf="@id/seven"
android:layout_width="@dimen/calc_dialog_button_width"
android:layout_height="@dimen/calc_dialog_button_height" />
<Button
android:id="@+id/nine"
android:text="9"
android:textSize="@dimen/calc_dialog_text_size"
android:layout_below="@id/enter_total"
android:layout_toRightOf="@id/eight"
android:layout_width="@dimen/calc_dialog_button_width"
android:layout_height="@dimen/calc_dialog_button_height" />
<Button
android:id="@+id/division"
android:text="÷"
android:textSize="@dimen/calc_dialog_text_size"
android:layout_below="@id/enter_total"
android:layout_toRightOf="@id/nine"
android:layout_width="@dimen/calc_dialog_button_width"
android:layout_height="@dimen/calc_dialog_button_height" />
<Button
android:id="@+id/four"
android:text="4"
android:textSize="@dimen/calc_dialog_text_size"
android:layout_below="@id/seven"
android:layout_alignParentLeft="true"
android:layout_width="@dimen/calc_dialog_button_width"
android:layout_height="@dimen/calc_dialog_button_height" />
<Button
android:id="@+id/five"
android:text="5"
android:textSize="@dimen/calc_dialog_text_size"
android:layout_below="@id/seven"
android:layout_toRightOf="@id/four"
android:layout_width="@dimen/calc_dialog_button_width"
android:layout_height="@dimen/calc_dialog_button_height" />
<Button
android:id="@+id/six"
android:text="6"
android:textSize="@dimen/calc_dialog_text_size"
android:layout_below="@id/seven"
android:layout_toRightOf="@id/five"
android:layout_width="@dimen/calc_dialog_button_width"
android:layout_height="@dimen/calc_dialog_button_height" />
<Button
android:id="@+id/multiply"
android:text="x"
android:textSize="@dimen/calc_dialog_text_size"
android:layout_below="@id/seven"
android:layout_toRightOf="@id/six"
android:layout_width="@dimen/calc_dialog_button_width"
android:layout_height="@dimen/calc_dialog_button_height" />
<Button
android:id="@+id/one"
android:text="1"
android:textSize="@dimen/calc_dialog_text_size"
android:layout_below="@id/four"
android:layout_alignParentLeft="true"
android:layout_width="@dimen/calc_dialog_button_width"
android:layout_height="@dimen/calc_dialog_button_height" />
<Button
android:id="@+id/two"
android:text="2"
android:textSize="@dimen/calc_dialog_text_size"
android:layout_below="@id/four"
android:layout_toRightOf="@id/one"
android:layout_width="@dimen/calc_dialog_button_width"
android:layout_height="@dimen/calc_dialog_button_height" />
<Button
android:id="@+id/three"
android:text="3"
android:textSize="@dimen/calc_dialog_text_size"
android:layout_below="@id/four"
android:layout_toRightOf="@id/two"
android:layout_width="@dimen/calc_dialog_button_width"
android:layout_height="@dimen/calc_dialog_button_height" />
<Button
android:id="@+id/subtract"
android:text="-"
android:textSize="@dimen/calc_dialog_text_size"
android:layout_below="@id/four"
android:layout_toRightOf="@id/three"
android:layout_width="@dimen/calc_dialog_button_width"
android:layout_height="@dimen/calc_dialog_button_height" />
<Button
android:id="@+id/decimal"
android:text="."
android:textSize="@dimen/calc_dialog_text_size"
android:layout_below="@id/one"
android:layout_alignParentLeft="true"
android:layout_width="@dimen/calc_dialog_button_width"
android:layout_height="@dimen/calc_dialog_button_height" />
<Button
android:id="@+id/zero"
android:text="0"
android:textSize="@dimen/calc_dialog_text_size"
android:layout_below="@id/one"
android:layout_toRightOf="@id/decimal"
android:layout_width="@dimen/calc_dialog_button_width"
android:layout_height="@dimen/calc_dialog_button_height" />
<Button
android:id="@+id/equals"
android:text="="
android:textSize="@dimen/calc_dialog_text_size"
android:layout_below="@id/one"
android:layout_toRightOf="@id/zero"
android:layout_width="@dimen/calc_dialog_button_width"
android:layout_height="@dimen/calc_dialog_button_height" />
<Button
android:id="@+id/addition"
android:text="+"
android:textSize="@dimen/calc_dialog_text_size"
android:layout_below="@id/one"
android:layout_toRightOf="@id/equals"
android:layout_width="@dimen/calc_dialog_button_width"
android:layout_height="@dimen/calc_dialog_button_height" />
</RelativeLayout>
</RelativeLayout>
.
@Override
protected Dialog onCreateDialog(int id) {
super.onCreateDialog(id);
Dialog dialog = null;
switch(id){
case 1:
dialog = new CustomCalcDialog(this, shippingPercent, QUICK_CALC_TRIGGER);
dialog.setTitle("Enter Shipping %");
break;
case 2:
dialog = new CustomCalcDialog(this, taxPercent, QUICK_CALC_TRIGGER);
dialog.setTitle("Enter Tax Rate");
break;
case 3:
dialog = new CustomCalcDialog(this, commissionPercent, QUICK_CALC_TRIGGER);
dialog.setTitle("Enter Commission %");
break;
case 4:
dialog = new CustomCalcDialog(this, productSubtotal, QUICK_CALC_TRIGGER);
dialog.setTitle("Calculate Subtotal");
break;
case 5:
dialog = new CustomCalcDialog(this, addShipping, QUICK_CALC_TRIGGER);
dialog.setTitle("Additional Shipping");
break;
case 6:
dialog = new BackgroundOptionsDialog(this, quickCalcBackground);
dialog.setTitle("Choose Background:");
break;
case 7:
dialog = new CustomCalcDialog(this, shippingDollar, QUICK_CALC_TRIGGER);
dialog.setTitle("Enter Shipping $");
break;
}
return dialog;
}