Manisha Patel
Manisha Patel

Reputation: 35

CardView-TextView marginRight

I am learning android. I am trying to set marginRight in my textview, but its cutting my text and showing empty space in layout. My XML is like below.

<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>

This is the image of my issue.... Please check and let me know.

enter image description here

Please check and let me know what I have wrong in this .

Thanks

Upvotes: 1

Views: 82

Answers (1)

SaravInfern
SaravInfern

Reputation: 3388

instead of maringLeft and marginRight use paddingLeft and paddingRight in your textView

  <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" />

Upvotes: 1

Related Questions