2016-07-10 10 views
1

Ich lerne Android. Ich versuche marginRight in meiner Textansicht zu setzen, aber es schneidet meinen Text und zeigt leeren Platz im Layout. Mein XML ist wie folgt.CardView-TextView marginRight

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



<android.support.v7.widget.CardView 
    android:id="@+id/quoteCard" 
    android:layout_marginTop="4dp" 
    android:layout_marginLeft="@dimen/activity_horizontal_margin" 
    android:layout_marginBottom="@dimen/activity_horizontal_margin" 
    android:layout_marginRight="@dimen/activity_horizontal_margin" 
    android:layout_width="match_parent" 
    android:elevation="3dp" 
    app:cardCornerRadius="6dp" 
    android:layout_height="match_parent"> 

    <ImageView 
     android:id="@+id/cardBackground" 
     android:scaleType="fitXY" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

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


     <de.hdodenhof.circleimageview.CircleImageView 
      android:layout_marginTop="20dp" 
      android:layout_gravity="center_horizontal" 
      android:id="@+id/authorImage" 
      android:layout_width="128dp" 
      android:layout_height="128dp" 
      app:civ_border_width="2dp" 
      app:civ_border_color="#99333333"/> 


     <TextView 
      android:layout_weight="1" 
      android:gravity="center" 
      android:layout_marginTop="6dp" 
      android:layout_marginRight="20dp" 
      android:layout_marginLeft="20dp" 
      android:layout_marginBottom="6dp" 
      android:lineSpacingExtra="15dp" 
      android:id="@+id/textDetailQuote" 
      android:text="The price of success is hard work, dedication to the job at hand, and the determination that whether we win or lose, we have applied the best of ourselves to the task at hand.Read more at: " 
      android:textSize="18sp" 
      android:textStyle="bold" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 


     <TextView 
      android:layout_marginBottom="10dp" 
      android:layout_marginRight="8dp" 
      android:id="@+id/textAuthorSign" 
      android:layout_gravity="right" 
      android:text="- ABJ Abdul Kalam" 
      android:textStyle="bold" 
      android:textSize="16sp" 
      android:visibility="invisible" 
      android:typeface="serif" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 



    </LinearLayout> 

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

Dies ist das Bild meiner Frage .... Bitte überprüfen und lassen Sie mich wissen.

enter image description here

Bitte überprüfen Sie und lassen Sie mich wissen, was ich in dieser falsch haben.

Dank

+0

Try 'android zu ändern: layout_width = "match_parent"' auf 'wrap_content' in Ihrem Textview. – Vucko

+0

@Vucko Danke für den Vorschlag, aber es zeigt immer noch das gleiche :( –

+0

Ich fand dies hilfreich, um die Konzepte von Padding und Marge zu verstehen, ich denke, Sie sind verwirrend sie: http://StackOverflow.com/Questions/4619899/Difference-between- a-views-padding-and-margin – Jonas

Antwort

1

statt maringLeft und margin paddingLeft und paddingRight in Ihrem Textview verwenden

<TextView 
     android:gravity="center" 
     android:layout_marginTop="6dp" 
     android:paddingRight="16dp" 
     android:paddingLeft="16dp" 
     android:layout_marginBottom="6dp" 
     android:lineSpacingExtra="15dp" 
     android:id="@+id/textDetailQuote" 
     android:text="The price of success is hard work, dedication to the job at hand, and the determination that whether we win or lose, we have applied the best of ourselves to the task at hand.Read more at: " 
     android:textSize="18sp" 
     android:textStyle="bold" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 
+0

Immer noch dasselbe Problem :( –

Verwandte Themen