3

当手机需要从 Web 服务检索一些数据时,我正在制作一个对话框以覆盖在屏幕上,问题是它的行为真的很奇怪:

对话框的大小问题

为什么imageView宽度高度设置为 **fill_parent)**没有填满分配给警报的整个空间?


这是显示警报的代码:

public class WaitDialog {

private static AlertDialog dialog;

public static void show(Activity pariente) {
    WindowManager.LayoutParams sizeParams = new WindowManager.LayoutParams();
    parametrosTamano.height = 128;
    parametrosTamano.width = 128;
    LayoutInflater inflater = (LayoutInflater)pariente.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View content = inflater.inflate(R.layout.waitingdialog, null);
    ImageView animation = (ImageView)contenido.findViewById(R.id.waitpic);
    animacion.startAnimation(AnimationUtils.loadAnimation(pariente, R.anim.animacionespera));
    AlertDialog.Builder builder = new AlertDialog.Builder(pariente);
    builder.setView(content);
    builder.setCancelable(false);
    dialog = constructor.create();
    dialog.show();
    //sizeParams.copyFrom(dialog.getWindow().getAttributes());
    dialog.getWindow().setAttributes(sizeParams);
    //dialog.getWindow().setLayout(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
}

public static void hide() {
    dialog.hide();
    dialog.dismiss();
    dialog = null;
}
}

这是被夸大的 XML:

<ImageView 
    android:id="@+id/imagenEspera"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    android:src="@drawable/animespera"
    android:scaleType="fitXY"
    android:layout_centerInParent="true"
    android:contentDescription="@string/espera"/>

难道我做错了什么?有一个更好的方法吗?

注意:有人可以解决上述混乱吗?

4

1 回答 1

1

你好 Drknezz,

          Please make the Layout for showing Alert and through Layout inflater show the alert. Like this

final Dialog _contiDialog=new Dialog(Qualify2.this,android.R.style.Theme_Translucent_NoTitleBar);
_contiDialog.setContentView(R.layout.continuedilog);

继续ilog.xml

<?xml version="1.0" encoding="utf-8"?>

<TextView android:id="@+id/TextView01" 
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" 
              android:text="Submit Your Score" 
              android:textStyle="bold"
              android:paddingTop="10dip"
              android:textColor="#000"/>

<LinearLayout 
              android:gravity="center" 
              android:layout_gravity="center_vertical|center_horizontal"
              android:layout_height="wrap_content"
              android:layout_width="fill_parent"
              android:paddingTop="10dip"
              android:orientation="vertical">

<RelativeLayout 
               android:paddingLeft="20dip"
               android:paddingRight="20dip"
               android:layout_height="wrap_content"
               android:layout_width="fill_parent">


   <TextView android:id="@+id/TextView02" 
             android:layout_width="wrap_content"
             android:layout_height="wrap_content" 
             android:layout_below="@+id/TextView01"
             android:textColor="#000" 
             android:text="Initial:"
              android:layout_alignParentLeft="true"
             android:textStyle="bold"/>

    <EditText 
              android:layout_width="150dip" 
              android:layout_height="35dip" 
              android:id="@+id/initials"
              android:layout_alignParentRight="true"
              android:textSize="12dip"
              android:singleLine="true" />

</RelativeLayout>


<RelativeLayout 
              android:gravity="center_horizontal|center_vertical"
              android:paddingLeft="20dip"
              android:paddingRight="20dip"
              android:layout_height="wrap_content"
              android:layout_width="fill_parent">

    <TextView android:id="@+id/TextView03" 
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" 
              android:textColor="#000"
              android:textStyle="bold"
              android:layout_alignParentLeft="true"
              android:text="Email: "/>

    <EditText 
              android:id="@+id/emails" 
              android:layout_width="150dip"
              android:layout_height="35dip"
              android:singleLine="true" 
              android:layout_alignParentRight="true"
              android:textSize="12dip"/>

</RelativeLayout>
<RelativeLayout 
             android:gravity="center_horizontal|center_vertical" 
              android:layout_height="wrap_content"
              android:layout_width="fill_parent"
               android:paddingLeft="20dip"
              android:paddingRight="20dip">

    <TextView android:id="@+id/TextView04" 
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" 
              android:layout_below="@+id/TextView03"
              android:textColor="#000"
              android:text="Smartphone:"
               android:layout_alignParentLeft="true"
              android:textStyle="bold"/>

    <Spinner android:prompt="@string/planet_prompt"
             android:id="@+id/smart_phone"
             android:layout_width="150dip" 
             android:layout_height="35dip"
              android:layout_alignParentRight="true"
             android:layout_below="@+id/emails"/>


</RelativeLayout>                         

<RelativeLayout 
             android:gravity="center_horizontal|center_vertical" 
              android:layout_height="wrap_content"
              android:layout_width="fill_parent"
               android:paddingLeft="20dip"
              android:paddingRight="20dip">

    <TextView android:id="@+id/TextView05" 
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" 
              android:textColor="#000" 
              android:text="Country: " 
               android:layout_alignParentLeft="true"
              android:textStyle="bold"/>

    <Spinner android:prompt="@string/planet_prompt1"
             android:id="@+id/country"
             android:layout_width="150dip" 
              android:layout_alignParentRight="true"
             android:layout_height="35dip"/>          
</RelativeLayout>

<CheckBox android:id="@+id/term1" android:layout_width="wrap_content"
    android:background="@drawable/checkbox_background"
    android:button="@drawable/checkbox"
    android:text="I accept the Terms and Conditions of this service. I know I will be sending my initials,email address, my handset model details,and my score to QuickNimble."
    android:textColor="#000" 
    android:layout_height="wrap_content" 
    android:textSize="12sp" 
    android:layout_marginLeft="9dip"></CheckBox>

<TextView android:layout_width="wrap_content"
              android:layout_height="10dip"/>

<CheckBox android:id="@+id/term2" 
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" 
          android:background="@drawable/checkbox_background"
          android:button="@drawable/checkbox"
          android:text="I would like to receive more information and offers from QuickNimble."
          android:textColor="#000" 
          android:textSize="12sp"
          android:layout_marginLeft="9dip"/>

于 2012-06-18T06:27:15.063 回答