2

I want to change text of Textview dynamically,

but it does not show full text.instead it shw one or two character less than it or sometimes show "...." atlast.

This is a layout for an custom equalizer.

This is my xml file.

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:id="@+id/fullscreenlnearlayout"
    android:paddingLeft="10dp"
    android:paddingRight="10dp">

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="0.38"
        android:gravity="center" >

        <Button
            android:id="@+id/btnformenu"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
             android:layout_alignParentStart="true"
            android:layout_alignParentLeft="true"
            android:text="Create New..." />


            <ImageButton
        android:id="@+id/refresh"
        android:contentDescription="Reset Equalizer to Default"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_margin="20dp"
        android:adjustViewBounds="false"
        android:alpha=".4"
        android:src="@drawable/refresh" 
       android:layout_marginTop="10dp"
            android:textAppearance="?android:attr/textAppearanceLarge" />

            <ToggleButton
                android:id="@+id/exit"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignParentEnd="true"
                android:layout_alignTop="@+id/refresh"
                android:layout_marginRight="15dp"
                android:layout_marginEnd="15dp"
                android:alpha=".4" />

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="wrap_content"
        android:id="@+id/horizontalscrollforequaliser"
        android:layout_height="0dp"
        android:isScrollContainer="false"
        android:layout_weight="1">

                <TextView
                    android:id="@+id/seekbar1kabottom"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentStart="true"
                    android:text="60Hz" />

                  <include
                      android:id="@+id/include5"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_above="@+id/seekbar1kabottom"
                      android:layout_alignTop="@+id/include7"
                       android:layout_marginStart="10dp"
                      android:layout_marginLeft="10dp"
                      android:layout_centerHorizontal="true"
                      layout="@layout/eq_bar" />

              <TextView
                  android:id="@+id/seekbar3katop"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_alignParentLeft="true"
                  android:layout_alignParentStart="true"
                  android:layout_alignParentTop="true"
                  android:layout_centerHorizontal="true"
                  android:singleLine="true"
                  android:text="0mB" />

                  <TextView
                   android:id="@+id/seekbar3kabottom"
                   android:singleLine="true"
                   android:layout_width="wrap_content"
                     android:layout_centerInParent="true"
                   android:layout_height="wrap_content"

                   android:layout_alignParentBottom="true"
                   android:layout_alignParentLeft="true"
                   android:layout_alignParentStart="true"

                   android:text="910Hz" />

           <include
               android:id="@+id/include7"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:layout_above="@+id/seekbar3kabottom"
               android:layout_alignParentLeft="true"
               android:layout_below="@+id/seekbar3katop"
               layout="@layout/eq_bar" />

 <include
     android:id="@+id/include"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_above="@+id/seekbar5kabottom"
     android:layout_alignParentEnd="true"
     android:layout_alignParentRight="true"
     android:layout_alignTop="@+id/include4"
     android:layout_marginLeft="10dp"
     android:layout_marginRight="10dp"
     android:layout_marginStart="10dp"
     layout="@layout/eq_bar" />

               <include
                   android:id="@+id/include4"
                     android:layout_marginStart="10dp"
                      android:layout_marginLeft="10dp"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:layout_alignBottom="@+id/include5"
                   android:layout_alignTop="@+id/include6"
                android:layout_toStartOf="@+id/include"
                   android:layout_toLeftOf="@+id/include"
                   layout="@layout/eq_bar" />

               <TextView
                   android:id="@+id/seekbar4katop"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:layout_above="@+id/include4"
                   android:layout_alignStart="@+id/include4"
                   android:layout_alignEnd="@+id/seekbar4kabottom"
                   android:layout_alignLeft="@+id/include4"
                   android:layout_alignRight="@+id/seekbar4kabottom"
                   android:singleLine="false"
                   android:text="0mB"/>

               <TextView
                   android:id="@+id/seekbar5kabottom"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:layout_alignParentRight="true"
                     android:layout_alignParentEnd="true"
                  android:singleLine="true"
                   android:layout_below="@+id/include4"
                   android:text="14KHz" />

               <TextView
                   android:id="@+id/seekbar4kabottom"
                   android:singleLine="true"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                    android:layout_alignStart="@+id/include4"
                   android:layout_alignLeft="@+id/include4"

                   android:layout_below="@+id/include4"
                   android:text="3600Hz" />

               <TextView
                   android:id="@+id/seekbar2kabottom"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:layout_alignLeft="@+id/include6"
                   android:layout_alignParentBottom="true"
                   android:singleLine="true"
                   android:text="230Hz" />

               <TextView
                   android:id="@+id/seekbar2katop"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:layout_above="@+id/include6"
                   android:layout_alignEnd="@+id/seekbar2kabottom"
                   android:layout_alignLeft="@+id/include6"
                   android:layout_alignParentTop="true"
                   android:layout_alignRight="@+id/seekbar2kabottom"
                   android:singleLine="false"
                   android:text="0mB" />

               <include
                   android:id="@+id/include6"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:layout_alignBottom="@+id/include7"
                   android:layout_below="@+id/seekbar1katop"
                   android:layout_marginStart="15dp"
                   android:layout_marginLeft="15dp"
                   android:layout_toRightOf="@+id/include7"
                   layout="@layout/eq_bar" />

               <TextView
                   android:id="@+id/seekbar5katop"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:layout_above="@+id/include"
                   android:layout_alignLeft="@+id/seekbar5kabottom"
                   android:layout_alignParentEnd="true"
                   android:layout_alignParentRight="true"
                   android:layout_alignParentTop="true"
                   android:layout_alignStart="@+id/include"
                   android:singleLine="false"
                   android:text="0mB" />

               <TextView
                   android:id="@+id/seekbar1katop"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:layout_above="@+id/include7"
                   android:layout_alignParentLeft="true"
                   android:layout_alignParentStart="true"
                   android:layout_alignRight="@+id/include7"
                   android:singleLine="false"
                   android:text="0mB" />

    </RelativeLayout>
</LinearLayout>

In picture you can see text s not coming u fully....it is not showing mB (unit) atlast.

I am trying this from several hours,but unable to do this Please give me a way to achieve this .

Thans in advance :)In picture you can see text s not coming u fully....it is not showing mB (unit) atlast

Animesh Mangla
  • 773
  • 7
  • 31

3 Answers3

2

You can decrease the text size of the TextView and see the changes. Ideally Android design guidelines specify that you create separate layouts for different screen sizes and resolutions. So on some devices the TextView font size would just fit fine but for others it'd have to be adjusted

zulkarnain shah
  • 971
  • 9
  • 20
  • As a quick fix I already asked you to decrease the text size of the TextView – zulkarnain shah Oct 01 '15 at 11:55
  • match_parent would make that TextView take up the whole width, but there are other TextViews also to be adjusted in the same horizontal row. – zulkarnain shah Oct 01 '15 at 11:57
  • yes that i know......i mean if u create seperate layout for each screen size ...........it will get aroud 200 layouts for each small app .. – Animesh Mangla Oct 01 '15 at 11:59
  • You're getting it wrong, there are only four screen size groups you have to target, MDPI, HDPI, XHDPI, XXHDPI and if you want to target old low resolution devices then LDPI too. – zulkarnain shah Oct 01 '15 at 12:01
  • Ohhk sorry.how u mention screen size in a layout.....i mean were to mention that this layout is for mdpi or hdpi ? – Animesh Mangla Oct 01 '15 at 12:05
  • You have to create different folders in your project for these different screen sizes and you should see the official design guidelines to know how to name those folders and what to put in them – zulkarnain shah Oct 01 '15 at 12:08
2

You can decrease Text size of the TextView . If you want remove .... You can remove this line

 android:singleLine="true"

and set width as match_parent or fill_parent .

IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
1

Remove wrap content and set a size using dp, it will probably work

Virthuss
  • 3,142
  • 1
  • 21
  • 39