2016-06-15 2 views
0

[Problem gelöst] Ich weiß nicht, warum die Höhe: wrap_content nicht funktioniert, wie ich erwartet habe, änderte ich es einfach, um Eltern zu entsprechen. Wie auch immer, Problem gelöst. Ich möchte nicht mehr Zeit mit diesem komischen Ding verbringen.android LinearLayout Anzeige Problem

Ich verwende LinearLayout, um das CardView zu erstellen. Ich bekomme jedoch diese seltsame Situation. Jinesh Francis Code funktioniert perfekt, aber wenn ich die Konfiguration in meinen Code kopiere und einfüge, bleibt das Problem gleich.

Normal Title

Long Long Title

Warum angezeigt nicht, kann der lange Titel vollständig?

ist das Layout wie folgt:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content"> 

<android.support.v7.widget.CardView 
    android:id="@+id/movieCardView" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="5dp" 
    android:layout_marginBottom="5dp" 
    android:layout_gravity="center" 
    android:background="@color/bacgroundCardView"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <ImageView 
      android:id="@+id/movieImage" 
      android:layout_width="70dp" 
      android:layout_height="90dp" 
      android:layout_marginBottom="4dp" 
      android:layout_marginLeft="4dp" 
      android:layout_marginRight="4dp" 
      android:layout_marginTop="4dp" 
      android:scaleType="fitXY" 
      android:src="@drawable/selfie" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:orientation="vertical" 
      android:layout_height="wrap_content"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_weight="1" 
       android:layout_height="0dp"> 

       <TextView 
        android:id="@+id/movieTitle" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="8" 
        android:textSize="15dp" 
        android:textColor="#000" 
        android:textStyle="bold" 
        android:text="Long long long long long long long long Title"/> 

       <TextView 
        android:id="@+id/movieRating" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="0.7" 
        android:textSize="12dp" 
        android:textStyle="bold" 
        android:text="7.0" /> 

       <CheckBox 
        android:id="@+id/checkBox" 
        android:layout_width="0dp" 
        android:layout_weight="1" 
        android:layout_height="wrap_content" 
        android:scaleX="0.70" 
        android:scaleY="0.70" /> 

      </LinearLayout> 

      <TextView 
       android:id="@+id/movieDescription" 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="1" 
       android:textSize="10dp" 
       android:text="So many many many many many many many many many many many many description" /> 

     </LinearLayout> 

    </LinearLayout> 

</android.support.v7.widget.CardView> 

Vielen Dank für jede Anregung

+0

Es ist nicht genug, um nur die XML-Tags zu schreiben. Bearbeiten Sie Ihren Post und fügen Sie die Attribute hinzu. – Karakuri

+0

posten Sie Ihre komplette Layout-Datei –

+0

Sie verwenden LinearLayout in relativeLayout, und Einstellung Gewicht des Titels .. deshalb gibt es diese Ausgabe – NehaK

Antwort

0

Versuchen mit linearen Layouts mit Gewichten wie anpassen dies

<?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="match_parent"> 
    <ImageView 
     android:layout_width="80dp" 
     android:layout_height="100dp" 
     android:src="@drawable/demo2"/> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:orientation="vertical" 
     android:layout_height="wrap_content"> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_weight="1" 
      android:layout_height="0dp"> 
      <TextView 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:textSize="20sp" 
       android:layout_weight="1" 
       android:textColor="#000" 
       android:textStyle="bold" 
       android:text="Long Long Long Long Long Tittle"/> 
      <TextView 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.25" 
       android:text="7.0"/> 
      <CheckBox 
       android:layout_width="0dp" 
       android:layout_weight=".25" 
       android:layout_height="wrap_content" /> 
     </LinearLayout> 
     <TextView 
      android:layout_width="match_parent" 
      android:text="so many many many many many many many many many many many many many many many many description" 
      android:layout_height="0dp" 
      android:layout_weight="1"/> 
    </LinearLayout> 
</LinearLayout> 

habe ich diese Ausgabe

Output

+0

Danke für Ihre Hilfe Jinesh. Es ist lustig, dass Ihr Code perfekt läuft, aber wenn ich die Konfiguration Zeile für Zeile aus Ihrem Code kopieren und einfügen, bleibt das Problem gleich, ich fühle mich von Android Studio täuschen ,, – Rangtian

2

Set RelativeLayout Immobilien für Ihr Layout

Relative Layout Property are below 
alignparentLeft,alignLeft 
alignparentRight,alignRight 
alignparentBottom,alignBottom 
alignparentTop,alignTop 
+0

Danke für Ihre Hilfe Divyesh, scheint, dass diese Eigenschaften nicht der Schlüssel sind. – Rangtian