2017-06-20 7 views
-1

Ich habe einen RecyclerView aufgebläht, der ein NetoworkImageView und 2 Textviews hat. Nach dem Aufblasen bekomme ich variable Größen für die Reihe, wie im Bild unten zu sehen ist.Aufgefüllter RecyclerView, der verschiedene Größen gibt

Wie könnte ich sie von fester Größe machen?

enter image description here

Dies ist das Layout I

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="50dp" 
android:gravity="center" 
android:orientation="horizontal" 
android:weightSum="10"> 

<com.android.volley.toolbox.NetworkImageView 
    android:id="@+id/imageView" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="center_horizontal" 
    android:layout_weight="2" 
    android:baselineAlignBottom="true" /> 

<TextView 
    android:id="@+id/textView_Status" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_weight="4" 
    android:gravity="center_vertical" 
    android:paddingLeft="13dp" 
    android:text="Testing" 
    android:textSize="17sp" /> 

<TextView 
    android:id="@+id/textView_Time" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_weight="2.5" 
    android:gravity="center_vertical" 
    android:text="Time" 
    android:textSize="17sp" /> 

<Button 
    android:id="@+id/button" 
    android:layout_width="50dp" 
    android:layout_height="50dp" 
    android:layout_gravity="center_horizontal" 
    android:visibility="invisible" /> 

EDIT bin Aufpumpen:

enter image description here

Antwort

0

verwenden wie Ihr Layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="50dp" 
android:gravity="center" 
android:orientation="horizontal" 
> 

<com.android.volley.toolbox.NetworkImageView 
    android:id="@+id/imageView" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="center_horizontal" 
    android:baselineAlignBottom="true" /> 

<TextView 
    android:id="@+id/textView_Status" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:gravity="center_vertical" 
    android:paddingLeft="13dp" 
    android:text="Testing" 
    android:textSize="17sp" /> 

<TextView 
    android:id="@+id/textView_Time" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:gravity="center_vertical" 
    android:text="Time" 
    android:textSize="17sp" /> 

<Button 
    android:id="@+id/button" 
    android:layout_width="50dp" 
    android:layout_height="50dp" 
    android:layout_gravity="center_horizontal" 
    android:visibility="invisible" /> 

Dadurch bleibt Ihr Bild nach links und der Rest des Raums wird gleichmäßig auf zwei Textansichten verteilt.

Wenn Sie eine Textansicht groß und eine kleine ändern möchten, ändern Sie das Gewicht von 1 auf 0,7 (klein) und 0,3 (groß).

+0

Ich habe dieses auch versucht und ich bekomme etwas ähnliches wie das, das ich im Screenshot in meiner Frage geschrieben habe. – Zx5

+0

Edited mein Code für die Ausrichtung verwenden Sie einfach übergeordnete Breite für textviews – sumit

+0

Es hat funktioniert !! Ich musste die Größen bearbeiten, aber ich hatte die Idee dazu. Danke vielmals! – Zx5

0

Ihr Code wie ändern:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="50dp" 
android:gravity="center" 
android:orientation="horizontal" 
> 

<com.android.volley.toolbox.NetworkImageView 
    android:id="@+id/imageView" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="center_horizontal" 
    android:baselineAlignBottom="true" /> 

<TextView 
    android:id="@+id/textView_Status" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:gravity="center_vertical" 
    android:paddingLeft="13dp" 
    android:text="Testing" 
    android:textSize="17sp" /> 

<TextView 
    android:id="@+id/textView_Time" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_weight="2" 
    android:gravity="center_vertical" 
    android:text="Time" 
    android:textSize="17sp" /> 

<Button 
    android:id="@+id/button" 
    android:layout_width="50dp" 
    android:layout_height="50dp" 
    android:layout_gravity="center_horizontal" 
    android:visibility="invisible" /> 

Es die beiden Textview in voller Größe der Breite wird nehmen besetzen, wenn es Text oder nicht.

+0

Ich habe versucht, und ich bekomme die einzige Zeit Feld unpassend. (Ich habe den Screenshot in der Frage gepostet) – Zx5

+0

Entschuldigung versehentlich Ihren Code bearbeitet – sumit

Verwandte Themen