Reputation: 683
I just implemented card view in my app, and want to put 2 different texts in it (one is 18dp, second is 9dp) in white space bellow image. Also I want to put arrow image to the right side of card view. But I'm getting problem there. If I use 2 different Textviews I can't allign the other one below the first one. And if I use only one Text view, I can't make the text have 2 different sizes.
Here's what I'm talking about:
As you can see, this is only one Text view wroten as Text1\nText2
I can't put size of 18dp to Text 1 and 9dp to Text 2.
Any solution to this??
Here's the XML code:
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
android:id="@+id/Vjezbe"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="2dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp"
android:layout_weight="1"
card_view:cardBackgroundColor="#ffffff"
android:layout_marginTop="55dp"
android:onClick="Vjezbe">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="130dp"
android:id="@+id/imageView6"
android:background="#000000"
android:layout_marginBottom="3dp"
android:layout_row="0"
android:layout_column="0" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Text 1\nText 2"
android:id="@+id/textView25"
android:textSize="18dp"
android:layout_marginLeft="10dp"
android:layout_weight="0.9" />
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/imageView17"
android:background="@mipmap/strelica"
android:layout_marginRight="6dp"
android:layout_marginTop="1dp"
android:layout_marginBottom="1dp" />
</TableRow>
</LinearLayout>
</android.support.v7.widget.CardView>
Upvotes: 3
Views: 10266
Reputation: 3353
Instead of using one TextView
Use LinearLayout
with orientation as vertical and add two text view
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="0.9" >
<TextView android:layout_width="wrap_content"
android:id="@+id/textView25"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Text 1"
android:textSize="18dp" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Text 2"
android:textSize="18dp" />
</LinearLayout>
Upvotes: 7