Android: Last line of textview cut off

后端 未结 20 1144
北荒
北荒 2020-11-28 02:46

I have a horizontal LinearLayout containing a TextView followed by a Spinner next to it. This LinearLayout is dynamically

相关标签:
20条回答
  • 2020-11-28 03:14

    I had the same problem and found a handy solution. I get the number of lines of the TextView after rendering and set the height according to the number of lines. Here is the code.

    TextView textView = (TextView) layout.findViewById(R.id.textView);
    textView.setText(this.text);
    textView.post(new Runnable() {
        @Override
        public void run() {
            int linesCount = textView.getLineCount();
            textView.setLines(linesCount);
        }
    });
    
    0 讨论(0)
  • 2020-11-28 03:19

    try with removing android:paddingBottom="20dp"

    from

     <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:paddingBottom="20dp"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:paddingTop="10dp" >
    
    0 讨论(0)
  • 2020-11-28 03:22

    I added some dummy space after text by adding

    textView.setText(firstString+"\n");
    

    I tried all other solution.But this was the only solution worked for me

    0 讨论(0)
  • 2020-11-28 03:23

    Add padding to the bottom of the text view:

    android:paddingBottom="24dp"
    
    0 讨论(0)
  • 2020-11-28 03:27

    I finally fixed it!

    I try to add String to the TextView in Service and then call scrollTo(), the last line be cut off!

    The scrollTo() should be call in "Runnable", like:

    private ScrollView mScrollView;
    public void scrollToBottom()
    {
        mScrollView = (ScrollView) findViewById(R.id.debug_textview_scrollview);
        mScrollView.post(new Runnable()
        {
            public void run()
            {
                mScrollView.fullScroll(View.FOCUS_DOWN);
            }
        });
    }
    

    I think it because in the monent of call scrollTo() in service, the update of TextView is not ready.

    0 讨论(0)
  • 2020-11-28 03:28

    I have this same problem, and its very annoying.

    It only happens with Arabic text.

    If you make the label multi-line and adding a \n at the end of your string, it would fix it, but the problem is that there would be a big gap between this label and the object below it, due to the fact that this field now has a new empty line below it.

    A custom control can be done to get around that. But overall, this is an annoying bug.

    0 讨论(0)
提交回复
热议问题