2017-06-05 4 views
0

J'ai une imageview & mise en page relative, où la mise en page contenant deux boutons doit aligner à fond et l'image circulaire devrait s'étirer pour prendre l'espace restant. J'ai essayé d'autres réponses mais je ne pouvais pas le faire. J'ai le code et l'image ci-dessous.Comment aligner la mise en page spécifique en bas et fixer la taille de l'image pour couvrir l'espace restant?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/cardview_light_background" 
android:clickable="true"> 
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <include layout="@layout/toolbar_child_with_progress" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/toolbar_child"/> 
    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@+id/toolbar_child"> 
     <RelativeLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      > 
       <ImageView 
        android:id="@+id/iv_SavedInvoice" 
        android:layout_width="wrap_content" 
        android:layout_height="match_parent" 
        android:src="@drawable/service_app_logo" 
        android:scaleType="fitStart" 
        android:adjustViewBounds="true" 
        android:layout_centerHorizontal="true" 
        /> 

       <LinearLayout 
        android:id="@+id/ll_inner" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="vertical" 
        android:layout_below="@+id/iv_SavedInvoice" 
        android:layout_alignParentBottom="true" 
        > 
        <Button 
         style="@style/PrimaryButton" 
         android:layout_marginTop="20dp" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="@string/form_proof_replace_invoice" 
         android:id="@+id/button_ReplaceInvoice" /> 
        <Button 
         style="@style/NoBorderButton" 
         android:layout_marginTop="20dp" 
         android:layout_marginBottom="20dp" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:text="@string/form_proof_next" 
         android:id="@+id/button_SavedProofNext" /> 
       </LinearLayout> 
      </RelativeLayout> 
    </ScrollView> 
</RelativeLayout> 

Align_Parent_Bottom

Répondre

1

Je ne sais pas pourquoi vous avez utilisé ScrollView et d'autres mises en page imbriquées. L'interface utilisateur que vous voulez peut être simplement réalisée en utilisant l'attribut poids de mise en page. Vous vérifiez ce code et effectuez les modifications en fonction de vos besoins. »

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/cardview_light_background" 
android:clickable="true" 
android:orientation="vertical"> 

<include 
    android:id="@+id/toolbar_child" 
    layout="@layout/toolbar_child_with_progress" 
    android:layout_width="match_parent" 
    android:layout_height="50dp" /> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1"> 

    <ImageView 
     android:id="@+id/iv_SavedInvoice" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_centerHorizontal="true" 
     android:adjustViewBounds="true" 
     android:scaleType="fitStart" 
     android:src="@mipmap/ic_launcher" /> 


</RelativeLayout> 

<LinearLayout 
    android:id="@+id/ll_inner" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_below="@+id/iv_SavedInvoice" 
    android:orientation="vertical"> 

    <Button 
     android:id="@+id/button_ReplaceInvoice" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="20dp" 
     android:text="form_proof_replace_invoice" /> 

    <Button 
     android:id="@+id/button_SavedProofNext" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="20dp" 
     android:text="form_proof_next" /> 
</LinearLayout> 

</LinearLayout> 
+0

merci, scrollview était le coupable. En fait, j'ai un autre code dans scrollview que je n'ai pas posté. J'ai décalé la disposition au-dessus de scrollview et cela fonctionne. –

+0

pouvez-vous me faire une autre petite faveur. J'ai utilisé "fitXY" pour ajuster la hauteur de l'image pour couvrir l'écart de hauteur jusqu'au bouton. Comment est-ce que je peux maintenir le rapport d'aspect de l'image de paysage et envoyer la largeur de l'image hors d'écran? –

+0

Replacer fitXY avec centerCrop. Il maintiendra la ration d'aspect. Mais il va recadrer une zone. Essayez ceci si ça va. Ou peut peut essayer une bibliothèque pour ImageView. –

0

Vous devez définir layout_heightmatch_parent au lieu de wrap_content.

<LinearLayout 
        android:id="@+id/ll_inner" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:orientation="vertical" 
        android:layout_below="@+id/iv_SavedInvoice" 
        android:layout_alignParentBottom="true" 
        > 

En second lieu, Ajouter android:fillViewport="true" dans votre ScrollView Section.

+0

Cela augmentera la hauteur des boutons contenant des lignes linéaires. Je veux que la hauteur de ll_inner soit statique. Je veux que la hauteur/largeur de l'image soit dynamique ici. J'ai essayé et je n'ai pas travaillé. –

+0

@BinodLama Ajouter 'android: fillViewport =" true "' dans la section ScrollView –

+0

Toujours pas de chance. N'a pas fonctionné. –