3

I need to show all data in TextView, it must occupy all the available space horizontally and contain all the data vertically(it is necessary for different screen sizes or device orientation).

But it does not take the necessary vertical area:

screen here

Is it a bug or have a way to solve my problem? While I just use LinearLayout, there is no such problem.

My XML:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
    tools:context="com.example.u_m0uk4.fortest.MainActivity">

    <TextView
        android:id="@+id/textView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="16dp"
        android:layout_marginLeft="132dp"
        android:layout_marginRight="16dp"
        android:layout_marginStart="132dp"
        android:layout_marginTop="16dp"
        android:text="Android («Андро́ид»[ком. 1]) — операционная система для смартфонов, интернет-планшетов, электронных книг, цифровых проигрывателей, наручных часов, игровых приставок, нетбуков, смартбуков, очков Google[2], телевизоров[3] и других устройств. В будущем планируется поддержка автомобилей[4] и бытовых роботов. оследствии Google инициировала создание альянса Open Handset Alliance (OHA), который сейчас занимается поддержкой и дальнейшим развитием платформы. Android позволяет создавать Java-приложения, управляющие устройством через разработанные Google библиотеки. Android Native Development Kit позволяет портировать библиотеки и компоненты приложений, написанные на Си и других языках.12345678912345678901234567890-1234567890"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="16dp" />

</android.support.constraint.ConstraintLayout>
Sufian
  • 6,405
  • 16
  • 66
  • 120
  • If i got your problem, is the text is showing in left side and you need to show it in centre. if yes you can remove the `android:layout_marginStart="132dp"` – Devendra Singh Sep 28 '16 at 12:28
  • @DevendraSingh thanks for reply, but this margins are necessary just for example. I can remove marginStart and marginLeft, but if a lot of text, it does not fit in the TextView anyway, although the vertical space still there. The question is - why does not stretch the field verticaly? – Vladimir Etc Sep 29 '16 at 06:46

2 Answers2

0

Please Refer below link, i hope it will work for you.

https://github.com/grantland/android-autofittextview

  • Thank you, but i need same text size. in my app there are a lot of TextViews and they have to have the text of the same size. – Vladimir Etc Sep 29 '16 at 06:52
  • @VladimirEtc. Then you have to set height and width wrap_content. and you have remove all margins. and if you able to give me a xml file than i will change it and give back to you with solution if i can. – Krunal Pujara Sep 29 '16 at 09:25
  • If i set height and width wrap_content, then width will be off screen. but in LinearLayout it's works. all the code shown above, just put it into ConstraintLayout. – Vladimir Etc Sep 29 '16 at 12:38
0

Fixed in 9 version. Now it works as i need.