2017-09-21 10 views
0

C'est ce dont j'ai besoin. Required output Mais je finis par utiliser pleine largeur en raison de alignParentRight = true ou l'horodatage est coupé pendant mes expériences.La largeur de la mise en page ne progresse pas pour tous les scénarios. J'obtiens la rangée supérieure pleine largeur (non désirée) ou ai l'horodatage coupé si le texte ci-dessous devient plus petit

Comment puis-je obtenir la sortie est comme ça.

enter image description here

Voici mon code.Please voir la mise en page qui ne fonctionne que si le texte est plus petite que la rangée supérieure. si le texte va grand, l'icône et l'horodatage ne marche pas s'aligné sur la largeur du texte, de façon appropriée ... ne pouvait pas le faire fonctionner ...

<?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="wrap_content" 
    android:orientation="horizontal"> 

    <View 
     android:id="@+id/divider" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/margin_10" 
     android:layout_marginBottom="@dimen/margin_10" 
     android:layout_marginTop="@dimen/margin_10" 
     android:background="@color/colorDarkGrey" 
     android:visibility="gone" /> 

    <RelativeLayout 
     android:id="@+id/checkbox_layout_id" 
     android:layout_width="35dp" 
     android:layout_height="match_parent" 
     android:layout_alignBottom="@+id/status_layt_id" 
     android:layout_alignTop="@+id/status_layt_id" 
     android:background="@android:color/darker_gray" 
     android:visibility="visible"> 

     <CheckBox 
      android:id="@+id/checkbox_id" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_centerVertical="true" /> 

    </RelativeLayout> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="8dp" 
     android:layout_marginRight="8dp" 
     android:layout_toRightOf="@+id/checkbox_layout_id" 
     android:paddingTop="8dp"> 

     <!--chat message holder--> 
     <LinearLayout 
      android:id="@+id/chat_message_holder" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 

      <LinearLayout 
       android:id="@+id/status_lyt_id" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/chat_white_bg_rounded_corner" 
       android:minWidth="130dp" 
       android:orientation="vertical"> 

       <!--header--> 
       <!--<include layout="@layout/adapter_comment_message_header"></include>--> 

       <LinearLayout 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:visibility="visible" 
        android:orientation="horizontal"> 

        <TextView 
         android:id="@+id/who_sent_id" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:fontFamily="sans-serif" 
         android:text="Directors name" 
         android:layout_marginLeft="12dp" 
         android:textColor="#696969" 
         android:layout_marginRight="16dp" 
         android:textSize="14sp" /> 
        <!--<LinearLayout--> 
        <!--android:layout_width="wrap_content"--> 
        <!--android:layout_height="wrap_content">--> 

        <ImageView 
         android:id="@+id/status_message_id" 
         android:layout_width="16dp" 
         android:layout_height="16dp" 
         android:layout_marginRight="4dp" 
         android:layout_toLeftOf="@+id/timestamp_id" 
         android:src="@drawable/chat_svg_not_reached_ic" 
         android:tint="#696969" /> 

        <TextView 
         android:id="@+id/timestamp_id" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentRight="true" 
         android:layout_gravity="right" 
         android:fontFamily="sans-serif" 
         android:gravity="right" 
         android:text="10:12 pm" 
         android:textColor="#696969" 
         android:textSize="14sp" 
         android:textStyle="normal" /> 
        <!--</LinearLayout>--> 
       </LinearLayout> 

       <!--content body--> 
       <LinearLayout 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="12dp" 
        android:orientation="vertical" 
        android:paddingBottom="8dp" 
        android:paddingRight="12dp" 
        android:paddingTop="0dp"> 

        <TextView 
         android:id="@+id/message_tv_id" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:fontFamily="sans-serif" 
         android:padding="0dp" 
         android:text="SomeSomeSomeSomeSome.." 
         android:textColor="#D8000000" 
         android:textSize="18sp" 
         android:visibility="visible" /> 
       </LinearLayout> 
      </LinearLayout> 
     </LinearLayout> 
    </RelativeLayout> 
</LinearLayout> 
+0

un peu de code s'il vous plaît – Nisarg

+0

@Nisarg nouveau à ce ... donc essayer de poster ici .. – Trellis

+0

son show bien nous votre fichier XML de mise en page – Nisarg

Répondre

0

Essayez cette mise en page au lieu de yours.Hope cela fonctionnera pour vous

<?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="80dp" 
android:orientation="horizontal"> 

<View 
    android:id="@+id/divider" 
    android:layout_width="match_parent" 
    android:layout_height="10dp" 
    android:layout_marginBottom="10dp" 
    android:layout_marginTop="10dp" 
    android:background="10dp" 
    android:visibility="gone" /> 

<RelativeLayout 
    android:id="@+id/checkbox_layout_id" 
    android:layout_width="55dp" 
    android:layout_height="match_parent" 
    android:background="@android:color/darker_gray" 
    android:visibility="visible"> 

    <CheckBox 
     android:id="@+id/checkbox_id" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerVertical="true" /> 

</RelativeLayout> 

<RelativeLayout 
    android:id="@+id/chat_message_holder" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent"> 

    <TextView 
     android:id="@+id/who_sent_id" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="12dp" 
     android:layout_marginRight="16dp" 
     android:fontFamily="sans-serif" 
     android:text="Directors name" 
     android:textColor="#696969" 
     android:textSize="14sp" /> 


    <!--<LinearLayout--> 
    <!--android:layout_width="wrap_content"--> 
    <!--android:layout_height="wrap_content">--> 

    <ImageView 
     android:id="@+id/status_message_id" 
     android:layout_width="16dp" 
     android:layout_height="16dp" 
     android:layout_marginRight="4dp" 
     android:layout_toRightOf="@+id/who_sent_id" 
     android:tint="#696969" /> 

    <TextView 
     android:id="@+id/timestamp_id" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="left" 
     android:fontFamily="sans-serif" 
     android:gravity="right" 
     android:text="10:12 pm" 
     android:textColor="#696969" 
     android:textSize="14sp" 
     android:textStyle="normal" 
     android:layout_toRightOf="@+id/message_layout" /> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_marginLeft="12dp" 
     android:orientation="vertical" 
     android:paddingBottom="8dp" 
     android:id="@+id/message_layout" 
     android:layout_below="@+id/who_sent_id" 
     android:paddingRight="12dp" 
     android:paddingTop="0dp"> 

     <TextView 
      android:id="@+id/message_tv_id" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fontFamily="sans-serif" 
      android:padding="0dp" 
      android:text="SomeSomeSome.." 
      android:textColor="#D8000000" 
      android:textSize="18sp" 
      android:visibility="visible" /> 
    </LinearLayout> 

</RelativeLayout> 

S'il vous plaît voir que je suis résultat suivant (image) pour 3 scénarios: 1) chevauchant première ligne lorsque le nom va grand 2) lorsque la deuxième rangée (texte) se développe, l'image ne marche pas rester à proximité écrire un SMS. J'ai bricolé cette partie avant et ne est pas facile pour moi ..

image ci-dessous: enter image description here

0

ceux qui ont essayé Appreciate me aider. Le poids est la seule méthode élastique si l'on veut faire croître quelque chose directement à partir d'un autre. Modification d'un échantillon posté par quelqu'un et cela fonctionne parfaitement bien. Peu importe qui pousse ABCD, en haut ou en bas, l'icône d'horloge et 1.111.111 ajustera élastique vers la droite

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/chat_message_holder" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@drawable/chat_white_bg_rounded_corner" 
    android:orientation="vertical"> 
    <!--chat message holder--> 

    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 
     <TextView 
      android:layout_weight="1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="abcdefghijklmnopqrstuvwxyz"> 
     </TextView> 
     <ImageButton 
      android:src="@drawable/chat_svg_not_reached_ic" 
      android:layout_width="16dp" 
      android:layout_height="16dp"> 
     </ImageButton> 
     <TextView 
      android:text="1111111" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 
     </TextView> 
    </LinearLayout> 
    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 
     <TextView 
      android:layout_weight="1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="abcdefghi"> 
     </TextView> 

    </LinearLayout> 
</LinearLayout>