Text inside cardview by half

Asked

Viewed 334 times

0

I wonder how I put the text inside a cardview higher.

inserir a descrição da imagem aqui

In my code it’s like this:

        <android.support.v7.widget.CardView
        android:id="@+id/card_view8"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_gravity="center"
        android:layout_margin="5dp"
        android:background="@color/colorPrimaryDark"
        card_view:cardCornerRadius="2dp"
        card_view:contentPadding="10dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <TextView
                android:id="@+id/textView26"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_alignParentTop="true"
                android:text="DETALHES"
                android:layout_centerInParent="true"
                android:textAppearance="?android:attr/textAppearanceLarge" />

        </RelativeLayout>
    </android.support.v7.widget.CardView>
  • 2

    Also enter your cardView code

  • Edit your question placing their codes to complement... But from what I took a quick look, I may be wrong, but you set the height of the cardView as 50dp, set to center whatever is inside it and are using a 10dp padding that is pushing your textView, and how he is Large, ends up getting cut up...

  • 1

    Try to give a paddingBottom, will solve this problem, you can go testing as it is by own preview of Android Studio

  • @Furflez did what you requested. Thanks for the tip.

  • @Leonardodias put so in the android code:paddingBottom="@dimen/activity_vertical_margin" and was the same thing.

1 answer

2

Cardview height is set with 50dp which does not seem to be sufficient for the height of the text.

Set the height of Cardview, Relativelayout, and Textview to wrap_content:

<android.support.v7.widget.CardView
    android:id="@+id/card_view8"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_margin="5dp"
    android:background="@color/colorPrimaryDark"
    card_view:cardCornerRadius="2dp"
    card_view:contentPadding="10dp">

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

        <TextView
            android:id="@+id/textView26"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_alignParentTop="true"
            android:text="DETALHES"
            android:layout_centerInParent="true"
            android:textAppearance="?android:attr/textAppearanceLarge" />

    </RelativeLayout>
</android.support.v7.widget.CardView>
  • 1

    I was forgetting to modify Relative Layout too. Solved my problem. Thanks for the help.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.