1

I am adding Text in textview but it clipping at start and I have tried adding padding, margin start and textalignment center or end.

screenshot of textview with text clipping at the starting edge

XML CODE

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#eb2f06"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity">

<android.support.v7.widget.CardView
    android:id="@+id/c1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/dim_2"
    android:visibility="invisible"
    app:cardBackgroundColor="#ffeb3b"
    app:cardCornerRadius="@dimen/dim_7"
    app:cardElevation="@dimen/dim_5"
    app:cardUseCompatPadding="true">


    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="vertical"
            android:padding="@dimen/dim_5">


            <TextView
                android:id="@+id/txtquote"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_margin="@dimen/dim_4"
                android:fontFamily="@font/dancingbold"
                android:padding="@dimen/dim_10"
                android:textColor="#000000"
                android:textSize="35sp" />

            <TextView
                android:id="@+id/txtauthor"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginEnd="@dimen/dim_3"
                android:layout_marginTop="@dimen/dim_3"
                android:fontFamily="@font/dancingbold"
                android:gravity="end"
                android:padding="@dimen/dim_5"
                android:textColor="#000000"
                android:textSize="30sp" />


         </LinearLayout>
    </ScrollView>
 </android.support.v7.widget.CardView>

Setting Content in java Java Code

    txtquote.setText("\"" + arrquote.get(count).quote + "\"");
    txtauthor.setText("~" + arrquote.get(count).author);

I have tried using hair space and \u0020

Firstly I thought it is because of my phone small screen but when I tried this in many different screen size phones, It still has the same problem

3
  • Did you try looking into this ==> stackoverflow.com/a/44218468/1282812 ? Commented Jul 16, 2018 at 7:14
  • @KalpeshPatel I tried looking to above link but I didn't understand a thing. Maybe you can help me
    – hrk singh
    Commented Jul 16, 2018 at 18:28
  • @andras Can take look at this problem
    – hrk singh
    Commented Jul 17, 2018 at 17:23

3 Answers 3

1

This is about the font properties(italic) and how android can measure/handle them. With that font afaik you won't be able get rid of clipping.

0

Try puting this instead of your scroll view, it will add a little space and i think it will not cut your text.

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical"
    android:padding="10dp">
-2

Try adding

android:clipToPadding="false"
android:clipChildren="false"

To the parent layouts of your TextViews.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.