0

I have ListView where I can add two TextView.

But I need to add NAME and INFO to one Button. What you can recommend me?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="7dp"
android:layout_marginTop="7.5dp"
android:layout_marginEnd="7dp"
android:layout_marginBottom="7.5dp"
android:background="@drawable/list_background"
android:elevation="5dp"
android:orientation="vertical"
android:paddingBottom="12dp">

<TextView
    android:id="@+id/subject_name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="15dp"
    android:textAllCaps="true"
    android:textColor="@color/textColor"
    android:textSize="30sp"
    tools:text="Name" />

<TextView
    android:id="@+id/subject_info"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingStart="15dp"
    android:paddingEnd="5dp"
    android:textColor="@color/infoColor"
    android:textSize="16sp"
    tools:text="Info" />

For example I want button like this button

Saif
  • 723
  • 6
  • 21

2 Answers2

0

make a xml named border_main in drawable

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners android:radius="7dp" />
    <solid android:color="#fff" />
    <stroke
        android:width="1dp"
        android:color="@color/white" />
</shape>

And use it like

 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
android:background="@drawable/border_main "
        android:orientation="horizontal"
        android:padding="10dp"
        android:id="@+id/lin"
        android:layout_margin="2dp"
 >-othetr components
</LinearLayout>
Developer
  • 333
  • 2
  • 16
0

Use Spannable string. You can set Size and Style span to change textsize and make it bold.

 String s= "Hello Everyone";
 SpannableString ss1=  new SpannableString(s);
 ss1.setSpan(new RelativeSizeSpan(2f), 0,5, 0); // set size
 StyleSpan boldSpan = new StyleSpan(Typeface.BOLD);
 ss1.setSpan(boldSpan, 0, 5, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
 TextView tv= (TextView) findViewById(R.id.textview);
 tv.setText(ss1);

The output is as below enter image description here

karan
  • 8,637
  • 3
  • 41
  • 78