1

エミュレーターでは問題なく表示されますが、デバイスでは奇妙に見えるAlertdialogを作成して表示します。

エミュレーターでは次のようになります。

ここに画像の説明を入力してください

これは、デバイスでどのように見えるかです。

ここに画像の説明を入力してください

これは、ダイアログを表示するために実行しているコードです。

    AlertDialog.Builder builder;
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);


    View layout = inflater.inflate(R.layout.popup_contact, (ViewGroup) findViewById(R.id.ppc_llContact));
    tbMissatge = (EditText) layout.findViewById(R.id.ppc_tbMissatge);
    builder = new AlertDialog.Builder(this);


    builder.setView(layout);
    ppEnviarMsg = builder.create();


    btEnviar = (Button) layout.findViewById(R.id.ppc_btEnviar);
    btEnviar.setOnClickListener(this);

    ppEnviarMsg.show();


    ppEnviarMsg.getWindow().getAttributes().gravity = Gravity.CENTER;

そしてここにポップアップのレイアウト:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/ppc_llContact"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#414145"
        android:orientation="vertical"
        android:gravity="center">

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#ffffff"
            android:text="@string/ppc_lbContact"
            android:layout_margin="4dp"/>

        <EditText
            android:id="@+id/ppc_tbMissatge"
            android:hint="@string/ppc_tooltipContact"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="2dp" 
            android:inputType="textMultiLine"
            android:gravity="top"
            android:lines="5">
        </EditText>

        <Button android:id="@+id/ppc_btEnviar"
            android:text="@string/ppc_btEnviar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:paddingLeft="20dp"
            android:paddingRight="20dp"
            android:layout_marginTop="10dp"/>

    </LinearLayout>

Senseと関係があるのでしょうか?私のデバイスは、ICSとSenseを実行しているHTCDesrieSです。誰か手がかりがありますか?

助けてくれてありがとう!

4

1 に答える 1

1

問題はここにあると思います:

View layout = inflater.inflate(R.layout.popup_contact, (ViewGroup) findViewById(R.id.ppc_llContact));

アクティビティの一部のレイアウトppc_llContactを「返された階層のルートに一連のLayoutParams値を提供するオブジェクト」として使用します。これは、このレイアウトがダイアログの最終階層に関与しないため、まったく意味がありません。

代わりにこれを使用してください:

View layout = inflater.inflate(R.layout.popup_contact, null);

もう1つのオプションは、次のようにダイアログのサイズを強制的に設定することです。

ppEnviarMsg.getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
//FILL_PARENT is an example
于 2012-11-16T11:08:53.527 に答える