2017-06-16 2 views
1

Ich versuche, ein cardview ähnlich diesem mit einem Bild mit Titel oben und dann einige Daten und vielleicht einige Aktionsschaltflächen unten zu erstellen. Aber für das Leben von mir kann ich nicht den Text oben auf dem Bild bekommen. enter image description herexamarin Kartenansicht Layout

Hier ist, was ich

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:cardview="http://schemas.android.com/apk/res-auto" 
android:id="@+id/card_view" 
android:layout_width="match_parent" 
android:layout_height="325dp" 
android:layout_margin="8dp"> 
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <ImageView 
     android:id="@+id/image1" 
     android:layout_width="match_parent" 
     android:layout_height="230dp" 
     android:layout_alignParentTop="true" 
     android:scaleType="centerCrop" /> 
    <TextView 
     android:id="@+id/recipeName" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/image1" 
     android:maxLines="3" 
     android:padding="8dp" 
     android:text="name" 
     android:textColor="#222" 
     android:textStyle="bold" 
     android:textSize="22dp" /> 
    <TextView 
     android:id="@+id/description" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/recipeName" 
     android:maxLines="3" 
     android:padding="8dp" 
     android:text="description" 
     android:textColor="#666" 
     android:textSize="14dp" /> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:layout_below="@+id/description"> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/recipeName" 
      android:maxLines="3" 
      android:padding="8dp" 
      android:text="View" 
      android:textColor="#666" 
      android:textSize="14dp" /> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/recipeName" 
      android:maxLines="3" 
      android:padding="8dp" 
      android:text="Add" 
      android:textColor="#666" 
      android:textSize="14dp" /> 
    </LinearLayout> 
</RelativeLayout> 

+1

Meinst du die Ebene der Textansicht? Können Sie uns Screenshots von Ihrer App geben, um einen besseren Eindruck zu bekommen? –

Antwort

2

bisher habe, werde ich nehme an, Sie @+id/recipeName oben auf @+id/image1 wollen.

Auf recipeName haben Sie festgelegt: android:layout_below="@+id/image1", die das Element unterimage1 Layout wird. Entfernen Sie diese Zeile, da Sie sie nicht unter diesem Element haben möchten. Versuchen Sie android:layout_alignBottom="@+id/image1". Es gibt genug Layoutparameter die meisten Dinge zu tun: LayoutParams, obwohl es ein bisschen wie ein Kaninchenbau sein können, wenn Sie komplexe Layouts tun beginnen ...

Auch Sie layout_below auf Elemente in Ihrem LinearLayout haben, die nicht mach alles.

+0

Ja, um den Namen des Rezepts unten auf dem Bild zu finden. Ich werde mir die verschiedenen Layoutparameter ansehen, die Sie erwähnt haben. Danke, Mann. –

+0

yep das hat den Trick gemacht. Danke noch einmal. –