1

AlertDialog を変更して、テキストが右揃えで表示されるようにしようとしています (ヘブライ語用)。

ここで inazaruk の助けを借りて: AlertDialog でテキストを右揃え にする ダイアログを表示することはできましたが、エミュレータ (Eclipse) でのみ正しく動作します。それを自分のデバイス (Xpersia X10a) に移動すると、アラート ボックスが画面の上部に表示され、背景がその背後のすべてをブロックします。

エミュレーター上の画像:

ここに画像の説明を入力

私のデバイス上の画像:

ここに画像の説明を入力

コード:

    public class test extends Activity {
    /** Called when the activity is first created. */

    public class RightJustifyAlertDialog extends AlertDialog {

        public RightJustifyAlertDialog(Context ctx) { 
              super(ctx, R.style.RightJustifyTheme); } }

   @Override
    public void onCreate(Bundle savedInstanceState) {
        final Context con = this;
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.main);

        Button button1 = (Button) findViewById(R.id.button1);
        button1.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                AlertDialog dialog = new RightJustifyAlertDialog(con);
                dialog.setButton("button", new OnClickListener(){           
                    public void onClick(DialogInterface arg0, int arg1)
                    {

                    }
                });

        dialog.setTitle("Some Title");
        dialog.setMessage("Some message");

        dialog.show();
            }

        });

    }
}

スタイル:

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

<style name="RightJustifyTextView" parent="@android:style/Widget.TextView">
    <item name="android:gravity">right|center_vertical</item>
    <item name="android:layout_centerVertical">true</item>
</style>

<style name="RightJustifyDialogWindowTitle" parent="@android:style/DialogWindowTitle" >
     <item name="android:gravity">right|center_vertical</item>
    <item name="android:layout_centerVertical">true</item>
</style>

<style name="RightJustifyTheme" parent="@android:style/Theme.Dialog.Alert">
    <item name="android:textViewStyle">@style/RightJustifyTextView</item>       
    <item name="android:windowTitleStyle">@style/RightJustifyDialogWindowTitle</item>       
</style>    

</resources>

私のデバイスは Android 2.1-update1 で動作しており、エミュレーターは同じに設定されています。

4

1 に答える 1

0

除外する簡単な方法の 1 つ...デバイスの他のアプリをチェックして、AlertDialog の背景のアルファ透明度がすべて削除されているかどうかを確認します。デフォルトのメール アプリケーションで何かを削除してみるか、アイテムを長押しして削除する他のアプリケーションを試すことができます。このスタイリングを変更する必要はないと思いますが、キャリアが最近何をするかはわかりません。

于 2011-05-29T15:08:20.877 に答える