ListView mit Bild und Text

  • Antworten:2
Lucas
  • Forum-Beiträge: 717

25.12.2014, 17:19:51 via Website

Hey Leute,
ich habe gerade folgendes Problem.
Und zwar möchte ich eine Liste machen (soweit kein Problem).
Dann möchte ich links ein Bild (quadratisch) und dann zwei Texte.

Mein Code sieht derzeit so aus:

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

    <TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/header"
        android:text="Header"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/imageView"
        android:textColor="@color/abc_primary_text_material_light"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/text"
        android:text="Text"
        android:layout_below="@+id/header"
        android:layout_alignLeft="@+id/header"
        android:layout_alignStart="@+id/header"
        android:textColor="@color/abc_secondary_text_material_light"/>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignBottom="@+id/text" />


</RelativeLayout>

Von der Höhe her passt sich das Bild an den Text an (so soll es sein) von der Breite her, entsteht aber ein breiter weißer Rand, je größer das Bild ist.

Ich hoffe mir kann da jemand helfen.

MfG
Lucas

Antworten
pepperonas
  • Forum-Beiträge: 434

25.12.2014, 22:39:25 via Website

Eine Liste lässt sich meiner Erfahrung nach in einem LinearLayout sehr gut darstellen...
Schau mal bei Youtube "slidenerd" hat da sehr gute Tuts gemacht ;)

Open Source

Antworten
Sven R.
  • Forum-Beiträge: 1.904

27.12.2014, 09:18:22 via App

Du könntest es statt mit einem RelativLayout mit einem LinearLayout für einen Datensatz versuchen. Die Liste würde ich lassen.

Wenn dir mein Beitrag gefällt, kannst dich einfach mit dem 👍 "Danke"-Button auf der Website dieses Forums bedanken. 😀

Why Java? - Because I can't C#

Antworten