0

I try to add custom quotation marks in my TextView. I create LinearLayout with horizontal and add start/end custom textview. Here is my source

            <LinearLayout
            android:id="@+id/description_container"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginLeft="@dimen/dimen_p_30"
            android:layout_marginTop="@dimen/dimen_p_25"
            android:layout_marginRight="@dimen/dimen_p_30"
            android:orientation="horizontal">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:fontFamily="@font/helvetica_regular"
                android:gravity="top"
                android:text="“"
                android:textColor="#E8E9EF"
                android:textSize="@dimen/dimen_p_46" />
            <TextView
                android:id="@+id/descriptionTextView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:fontFamily="@font/myriad_geo_medium"
                android:gravity="top"
                android:maxLines="150"
                android:text="test message"
                android:textColor="@color/gray"
                android:textSize="@dimen/dimen_p_14" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:fontFamily="@font/helvetica_regular"
                android:gravity="bottom"
                android:text="”"
                android:textColor="#E8E9EF"
                android:textSize="@dimen/dimen_p_46" />

        </LinearLayout>

Everything is working perfect but when my descriptionTextView has large text and it need two lines, 3th textview does not showing.Is a any way to solve this problem or does my way is a correct? Thanks

ppreetikaa
  • 1,149
  • 2
  • 15
  • 22
BekaKK
  • 2,173
  • 6
  • 42
  • 80

2 Answers2

0

Use weight for your TextViews like this

   <LinearLayout
    android:id="@+id/description_container"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginLeft="@dimen/dimen_p_30"
    android:layout_marginTop="@dimen/dimen_p_25"
    android:layout_marginRight="@dimen/dimen_p_30"
    android:orientation="horizontal"
    android:weightSum="3"
    >

    <TextView
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:fontFamily="@font/helvetica_regular"
        android:gravity="top"
        android:text="“"
        android:textColor="#E8E9EF"
        android:textSize="@dimen/dimen_p_46" />
    <TextView
        android:id="@+id/descriptionTextView"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:fontFamily="@font/myriad_geo_medium"
        android:gravity="top"
        android:maxLines="150"
        android:text="test message"
        android:textColor="@color/gray"
        android:textSize="@dimen/dimen_p_14" />

    <TextView
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:fontFamily="@font/helvetica_regular"
        android:gravity="bottom"
        android:text="”"
        android:textColor="#E8E9EF"
        android:textSize="@dimen/dimen_p_46" />

</LinearLayout>
AA Shakil
  • 538
  • 4
  • 14
Sandeep dhiman
  • 1,863
  • 2
  • 17
  • 22
0

Add your complete text with Exclamations to only one TextView. Use Spannable string to set color to exclamations.

TextView textView = (TextView)findViewById(R.id.mytextview01);    
String mText = textView.getText();
Spannable wordtoSpan = new SpannableString(mText);          
wordtoSpan.setSpan(new ForegroundColorSpan(Color.BLUE), 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);    
wordtoSpan.setSpan(new ForegroundColorSpan(Color.BLUE), (mText.Length()-2), (mText.Length()-1), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);    
textView.setText(wordtoSpan);
karan
  • 8,637
  • 3
  • 41
  • 78