2017-08-14 6 views
1

ich RecyclerView verwende und das ist der Code für activity_main:Image Überschneidungen mit Textview in ConstraintLayout

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.example.romin.apodbrowser.MainActivity"> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/recyclerView" 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="8dp" 
    android:layout_marginLeft="8dp" 
    android:layout_marginRight="8dp" 
    android:layout_marginTop="8dp" 
    android:scrollbars="vertical" 
    app:layout_constraintBottom_toBottomOf="parent" 
    app:layout_constraintHorizontal_bias="0.0" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintRight_toRightOf="parent" 
    app:layout_constraintTop_toTopOf="parent" /> 
</android.support.constraint.ConstraintLayout> 

Und für die RecyclerView Artikel Dies ist das Layout:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/list_item" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical"> 

<org.sufficientlysecure.htmltextview.HtmlTextView 
    android:id="@+id/title" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginEnd="8dp" 
    android:layout_marginLeft="8dp" 
    android:layout_marginRight="8dp" 
    android:layout_marginStart="8dp" 
    android:text="TextView" 
    android:textSize="24sp" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintRight_toRightOf="parent" 
    tools:layout_editor_absoluteY="16dp" /> 

<TextView 
    android:id="@+id/pubDate" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginEnd="8dp" 
    android:layout_marginLeft="8dp" 
    android:layout_marginRight="8dp" 
    android:layout_marginStart="8dp" 
    android:layout_marginTop="8dp" 
    android:text="TextView" 
    android:textAppearance="@style/TextAppearance.AppCompat" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintRight_toRightOf="parent" 
    app:layout_constraintTop_toBottomOf="@+id/link" /> 

<ImageView 
    android:id="@+id/image" 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:layout_marginEnd="8dp" 
    android:layout_marginLeft="8dp" 
    android:layout_marginRight="8dp" 
    android:layout_marginStart="8dp" 
    android:layout_marginTop="8dp" 
    android:adjustViewBounds="true" 
    android:scaleType="fitStart" 
    app:layout_constraintHorizontal_bias="0.0" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintRight_toRightOf="parent" 
    app:layout_constraintTop_toBottomOf="@+id/pubDate" 
    app:srcCompat="@drawable/default_image" /> 


<org.sufficientlysecure.htmltextview.HtmlTextView 
    android:id="@+id/description" 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/image" 
    android:layout_marginBottom="8dp" 
    android:layout_marginEnd="8dp" 
    android:layout_marginLeft="8dp" 
    android:layout_marginRight="8dp" 
    android:layout_marginStart="8dp" 
    android:layout_marginTop="8dp" 
    android:text="TextView" 
    android:textSize="16sp" 
    app:layout_constraintBottom_toBottomOf="parent" 
    app:layout_constraintHorizontal_bias="0.0" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintRight_toRightOf="parent" 
    app:layout_constraintTop_toBottomOf="@+id/image" 
    tools:text="Description" /> 

<TextView 
    android:id="@+id/link" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginEnd="8dp" 
    android:layout_marginLeft="8dp" 
    android:layout_marginRight="8dp" 
    android:layout_marginStart="8dp" 
    android:layout_marginTop="8dp" 
    android:text="TextView" 
    android:textSize="16sp" 
    app:layout_constraintHorizontal_bias="1.0" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintRight_toRightOf="parent" 
    app:layout_constraintTop_toBottomOf="@+id/title" 
    tools:text="LINK" /> 
</android.support.constraint.ConstraintLayout> 

Grundsätzlich gibt es der Titel oben, der Link und das PubDate. Dann gibt es das Bild und dann die Beschreibung. Neben dem Bild (ImageView) sind alle anderen TextViews.

Das Problem ist, dass, wenn ich ein Bild von einem RSS-Feed auf die ImageView laden, und die Miniaturansicht verschwunden ist, die ImageView mit der Beschreibung TextView überlappt. Ich habe überall gesucht, aber ich kann keine Lösung finden. Ich verstehe, dass die Bitmap ihre Größe und nicht die ImageView ändert, und höchstwahrscheinlich verursacht das die Überlappung, aber ich finde keine Möglichkeit, sie zu beheben.

Vielen Dank im Voraus.

Screenshot:

[https://i.stack.imgur.com/e2eMA.jpg][1]

+0

können Sie ein Bild posten, um eine Idee zu bekommen, wie und wo es sich überschneidet? –

+0

@AalapPatel Ich habe die Frage bearbeitet, um am Ende einen Screenshot einzufügen. Vielen Dank! – hms

Antwort

0

Entfernen Sie die folgende Zeile aus description:

app:layout_constraintBottom_toBottomOf="parent" 

Dies wird wirksam die Beschreibung Ansicht unterhalb des Bildes bewegen. Ich habe es gerade getestet und es funktioniert.

Ich hoffe, das hilft.

+0

Ich habe Ihre Lösung versucht, aber das Bild scheint jetzt nicht die Ansichtsgrenzen anzupassen. Seine Position befindet sich nicht in der Mitte mit gleichem Abstand von links und rechts, obwohl ich scaleType auf fitStart und adjustViewBounds auf true setze. – hms

+0

@hms Ich habe das XML falsch gelesen. Ich werde es wieder versuchen. Ihre Beschreibung ist auf den unteren Rand des übergeordneten Elements und auf das untere Ende des Bildes beschränkt. Ist das Bild so groß, dass es die Beschreibung überlappt, weil die Beschreibung keinen Platz zwischen dem Bild und dem Elternboden hat? Wenn das der Fall ist, was willst du passieren? Kannst du einen Screenshot posten, um die Dinge klarer zu machen? – Cheticamp

+0

@hms Siehe aktualisierte Antwort. – Cheticamp

Verwandte Themen