2012-01-24 3 views
0

Je veux ajouter une boîte de dialogue personnalisée, mais j'ai des problèmes pour créer un xml comme je veux ..Custom Dialog xml

Voici ce que j'imagine:

[IMAGE] [TEXTE]

[ ScrollableText]

[BOUTON] [BOUTON] [BOUTON]

Et mon xml:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/LinearLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:id="@+id/linearLayout2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <ImageView 
      android:id="@+id/imgMentor" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:src="@drawable/changelogicon" /> 

     <TextView 
      android:id="@+id/tvSubject" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="--" 
      android:textColor="#FFF" 
      android:textSize="20px" /> 
    </LinearLayout> 

    <ScrollView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/layout_root" 
     android:layout_width="fill_parent" 
     android:layout_height="match_parent" 
     android:padding="10dp" > 

     <TextView 
      android:id="@+id/tvExplanation" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="7dip" 
      android:text="--" 
      android:textColor="#FFF" /> 
    </ScrollView> 

    <LinearLayout 
    android:id="@+id/linearLayout2" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:baselineAligned="true" > 


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


    <Button 
     android:id="@+id/button2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Button" /> 


    <Button 
     android:id="@+id/button3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Button" /> 

</LinearLayout> 

</LinearLayout> 

image, texte et texte scrollable belle apparence, mais si le texte au milieu est trop long et devenir scrollable, mes boutons sont allés ..

Qu'est-ce que je fait de mal?

EDIT: ma solution:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/RelativeLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <ImageView 
     android:id="@+id/imgIcon" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:src="@drawable/changelogicon" /> 

    <TextView 
     android:id="@+id/tvSubject" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/imgIcon" 
     android:layout_marginBottom="15dp" 
     android:layout_toRightOf="@+id/imgIcon" 
     android:text="--" 
     android:textColor="#FFF" 
     android:textSize="20px" /> 

    <ScrollView 
     android:id="@+id/layout_root" 
     android:layout_width="fill_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@+id/button1" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/imgIcon" 
     android:layout_marginTop="20dp" > 

     <TextView 
      android:id="@+id/tvExplanation" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="7dip" 
      android:text="--" 
      android:textColor="#FFF" /> 
    </ScrollView> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:text="Button" /> 

    <Button 
     android:id="@+id/button2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:text="Button" /> 

    <Button 
     android:id="@+id/button3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:text="Button" /> 

</RelativeLayout> 
+0

essayé de mettre scrollview en dehors de votre disposition linéaire principale ..? – Hiral

Répondre

1

Utilisez un RelativeLayout plutôt qu'un LinearLayout comme l'élément de niveau supérieur dans la hiérarchie de votre vue. LinearLayout s ne font pas très bien à gérer ce genre de scénario "remplir le milieu".

Avec un RelativeLayout vous pouvez aligner vos boutons avec le fond, votre texte/image avec le haut, puis aligner votre ScrollView être en dessous du texte/image et au-dessus des boutons, l'étirer en conséquence.

Jetez un coup d'œil au tutoriel "Hello RelativeLayout" pour plus d'informations.

Astuce rapide: Si vous augmentez votre taux d'acceptation, plus de personnes répondront à votre question.

+0

Parfait, merci beaucoup! :) – Prexx