2016-07-01 10 views
0

Ich benutze CardView, um mein Zitat mit Autorbild zu listen. Ich versuche, Zitat in der Mitte horizontal in der Liste zu setzen. Ich habe versucht, Schwerpunkt und verwandte Methode. Aber ich bin kein Erfolg. Meine aktuelle Ansicht zeigt wie untenZentraler horizontaler Text

Aktuelle

enter image description here

Need

enter image description here

My XML ist wie unten

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
xmlns:app="http://schemas.android.com/apk/res-auto"> 


<android.support.v7.widget.CardView 

    android:layout_marginTop="4dp" 
    android:layout_marginBottom="4dp" 
    app:cardElevation="4dp" 
    app:cardCornerRadius="6dp" 
    android:layout_marginLeft="8dp" 
    android:layout_marginRight="8dp" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <LinearLayout 
     android:id="@+id/quoteActionView" 
     android:clickable="true" 
     android:background="?attr/selectableItemBackground" 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <ImageView 
      android:visibility="visible" 
      android:id="@+id/imageAuthorView" 
      android:scaleType="fitXY" 
      android:layout_width="150dp" 
      android:layout_height="150dp" /> 
     <TextView 
      android:visibility="gone" 
      android:id="@+id/textIndxQuote" 
      android:padding="8dp" 
      android:gravity="center" 
      android:background="#444444" 
      android:textColor="@android:color/white" 
      android:textStyle="bold|italic" 
      android:textSize="16sp" 
      android:layout_width="48dp" 
      android:layout_height="match_parent" /> 

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

      <TextView 
       android:id="@+id/textQuote" 
       android:scrollHorizontally="true" 
       android:ellipsize="end" 
       android:maxLines="2" 
       android:textSize="40sp" 
       android:textStyle="bold" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 

     </LinearLayout> 

    </LinearLayout> 

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

Bitte überprüfen Sie und lassen Sie mich wissen, was ich vermisst.

Dank

Antwort

1

Ihr letztes Linearlayout Um dies zu ändern:

<LinearLayout 
     android:layout_margin="8dp" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_gravity="center" 
     android:layout_height="wrap_content"> 
+0

hallo @babadaba! es funktioniert gut :) Danke für die Hilfe :) –

0

Set LinearLayout Höhe match_parent und setzen android:layout_gravity:"center" oder android:layout_gravity:"center_vertical" in seinem Inneren. Sollte funktionieren.

Verwandte Themen