2013-07-05 16 views
7

Aşağıda bu düzen oluşturmak için trtying yapıyorum, ancak ihtiyacım olan doğru düzenini görebiliyorum. Yapmaya çalıştığım şey, bir düzen kullanarak bir özelleştirme kutusu kutusuna sahip. Aşağıdaki xml'yi düzenlemeyi denedim, ancak bu bir iletişim kutusu olarak gösteriliyorsa, tanımlı düzen karmaşadır. Lütfen bu için ne yapmam gerektiğini anlatayım. Teşekkürler ve sabırsızlıkla bekliyorum. İletişim kutusu GÖSTER, ancak düzen karşılanmaz.Android - Bir Xml Düzeni kullanarak Dialog'u Özelleştirme

enter image description here

Diyalog:

View checkBoxView = View.inflate(this, R.layout.display_item_dialog, null); 
CheckBox checkBox = (CheckBox)checkBoxView.findViewById(R.id.checkBox1); 
checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { 

    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 
     // Save to shared preferences 
    } 
}); 
checkBox.setText("Search All Images"); 
AlertDialog.Builder builder = new AlertDialog.Builder(this); 
builder.setTitle("Image Preferences"); 
builder.setMessage(" Select from below ") 
.setView(checkBoxView) 
.setCancelable(false) 
.setPositiveButton("Yes", new DialogInterface.OnClickListener() { 
    public void onClick(DialogInterface dialog, int id) { 
    } 
}) 
.setNegativeButton("No", new DialogInterface.OnClickListener() { 
    public void onClick(DialogInterface dialog, int id) { 
     dialog.cancel(); 
    } 
}).show(); 

display_item_dialog.xml

<?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" 
     android:layout_alignParentLeft="true" 
     android:text="Map Category: BEVERAGES" /> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="200dip" 
     android:layout_height="200dip" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/textView1" 
     android:layout_marginTop="14dp" 
     android:src="@drawable/sunny" /> 

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_centerVertical="true" 
     android:text="TextView" /> 

    <TextView 
     android:id="@+id/textView3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/textView2" 
     android:layout_marginTop="28dp" 
     android:text="TextView" /> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignTop="@+id/imageView1" 
     android:layout_marginRight="20dp" 
     android:layout_marginTop="47dp" 
     android:text="+" /> 

    <Button 
     android:id="@+id/button2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/textView2" 
     android:layout_alignLeft="@+id/button1" 
     android:layout_marginBottom="14dp" 
     android:text="-" /> 

    <EditText 
     android:id="@+id/editText1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/button2" 
     android:layout_alignRight="@+id/button2" 
     android:layout_below="@+id/button1" 
     android:ems="10" 
     android:clickable="false" > 

     <requestFocus /> 
    </EditText> 

    <CheckBox 
     android:id="@+id/checkBox1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/textView3" 
     android:layout_marginTop="33dp" 
     android:text="CheckBox" /> 

</RelativeLayout> 

cevap

5

bu deneyin:

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

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Map Category: BEVERAGES" /> 

    <LinearLayout 
     android:id="@+id/linear" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="14dp" 
     android:gravity="center_vertical" > 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="0dp" 
      android:layout_height="200dip" 
      android:layout_weight="0.6" 
      android:src="@drawable/ic_launcher" /> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.4" 
      android:orientation="vertical" > 

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

      <Button 
       android:id="@+id/button1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:text="+" /> 

      <EditText 
       android:id="@+id/editText1" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:clickable="false" > 

       <requestFocus /> 
      </EditText> 

      <Button 
       android:id="@+id/button2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:text="-" /> 
     </LinearLayout> 
    </LinearLayout> 

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

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

    <CheckBox 
     android:id="@+id/checkBox1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="CheckBox" /> 
</LinearLayout> 

</ScrollView> 
+1

hala bir sorun varsa, tüm düzeni "ScrollView" içine koyun. –

+0

Kesinlikle, bunun için teşekkürler. İşe yaradı.!!! – rahstame

+0

Sevindim Yardımcı olabilirim. Bir yanıt olarak kabul edin :) –

6
Bu başvurabilirsiniz

Derslikler

Bu düzen ben başarmaya çalışıyorum budur

http://www.mkyong.com/android/android-custom-dialog-example/

 final Dialog dialog = new Dialog(context); 
     dialog.setContentView(R.layout.custom); 
     dialog.setTitle("Title..."); 

     // set the custom dialog components - text, image and button 
     TextView text = (TextView) dialog.findViewById(R.id.text); 
     text.setText("Android custom dialog example!"); 
     ImageView image = (ImageView) dialog.findViewById(R.id.image); 
     image.setImageResource(R.drawable.ic_launcher); 

     Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK); 
     // if button is clicked, close the custom dialog 
     dialogButton.setOnClickListener(new OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       dialog.dismiss(); 
      } 
     }); 

     dialog.show(); 
+0

hi! Yukarıda istenen düzeni ekledim. Şu anda istediğim xml düzeni Nirali ile biraz endişe duyuyorum. – rahstame

+0

XML görünümünüzü görüntü başına istediğiniz gibi ayarlayamayacağınız anlamına mı geliyor? – Nirali

+0

Yukarıdaki resim, iletişim penceremi görüntülemem gereken veya iletişim kutusu yukarıdaki görüntüyle aynı görünmesi gereken. Xml efendim ile çalışmam gerek. – rahstame