2012-03-22 6 views
0

アラートダイアログをレイアウトでカスタマイズしようとしています。問題は、[アラート]ダイアログボックスが小さいサイズでランチされ、レイアウトのほとんどがトランケートされているか、または単語が重複していることです。ダイアログボックスが非常に小さく、すべての内容をカバーするように拡大していないため、画面の問題ではありません。なぜこれが起こっていると思いますか?アラートダイアログにその内容がすべて表示されない理由

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

    <LinearLayout 
     android:id="@+id/linearLayout2" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/linearLayout1" 
     android:layout_alignParentLeft="true" 
     android:orientation="horizontal" > 

     <TextView 
      android:id="@+id/tvNa" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.5"/> 

     <EditText 
      android:id="@+id/etNa" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" /> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/linearLayout1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_centerVertical="true" 
     android:orientation="horizontal" > 

     <TextView 
      android:id="@+id/tvQ" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.5"/> 

     <EditText 
      android:id="@+id/etQ" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" /> 

    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/linearLayout3" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/linearLayout1" 
     android:layout_centerVertical="true" 
     android:orientation="horizontal" > 

     <TextView 
      android:id="@+id/tvP" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.5" /> 

     <EditText 
      android:id="@+id/etP" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:inputType="numberDecimal" /> 

    </LinearLayout> 

</RelativeLayout> 

をそして私は、次のコードを使用しています:

私は、次のレイアウトを使用しています

AlertDialog.Builder alert = new AlertDialog.Builder(this); 
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 

View layout = inflater.inflate(R.layout.add_dialog, null); 
alert.setView(layout); 
alert.setTitle("New one"); 
alert.setPositiveButton("Ok",new DialogInterface.OnClickListener() { 
@Override 
    public void onClick(DialogInterface dialog, int whichButton) { 


    } 
}); 
alert.setNegativeButton("Cancel",new DialogInterface.OnClickListener() { 
@Override 
    public void onClick(DialogInterface dialog, int whichButton) { 

    } 
}); 
alert.show(); 
+0

'alert.setContentView(R.layout.add_dialog)' –

+0

存在しません。これはダイアログではなくアラートダイアログです。それはsetViewを持っていて、私はそれを上で使った – Snake

答えて

0

ダイアログオブジェクトは、あなたが書かれていない上で持って、設定された最大サイズを持っています。レイアウトをScrollViewに追加することができます。それ以外の場合は、最大ダイアログサイズが設定されている場所を見つけてこれを無効にするまで、Dialogの継承に従わなければなりません。 GrepCodeは、SDKソースを表示するのに適しています。

関連する問題