java - TextView and scale -


i use code

textview.animate().setduration(0).scalex(scale).scaley(scale).start(); 

when scale value increase point, make textview disappear. dont know why, , how prevent it?

[edit] attach test code

[test_text_scale.xml] layout xml file testtextscale.java

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:clipchildren="false"     android:orientation="vertical">      <textview         android:id="@+id/tv_test_scale"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_centerinparent="true"         android:text="test" />      <button         android:id="@+id/bt_up"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentbottom="true"         android:layout_toendof="@+id/bt_down"         android:layout_torightof="@+id/bt_down"         android:text="up" />      <button         android:id="@+id/bt_down"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentbottom="true"         android:layout_alignparentleft="true"         android:layout_alignparentstart="true"         android:text="down" />  </relativelayout> 

[testtextscale.java]

import android.os.bundle; import android.support.annotation.nullable; import android.support.v7.app.appcompatactivity; import android.view.view; import android.widget.button; import android.widget.textview;   public class testtextscale extends appcompatactivity {      // view     private textview mtvtestzoom;     private button mbtup, mbtdown;      // model     private int mcurrentscale = 1;      // onclick listener     private view.onclicklistener monclicklistener = new view.onclicklistener() {         @override         public void onclick(view v) {             switch (v.getid()) {                  case r.id.bt_up : {                     upscale();                     settext();                 } break;                  case r.id.bt_down : {                     downscale();                     settext();                 } break;             }         }     };      @override     protected void oncreate(@nullable bundle savedinstancestate) {         super.oncreate(savedinstancestate);          setcontentview(r.layout.test_text_scale);          initview();         initevent();     }      private void initview() {          mtvtestzoom = (textview) findviewbyid(r.id.tv_test_scale);         mbtup = (button) findviewbyid(r.id.bt_up);         mbtdown = (button) findviewbyid(r.id.bt_down);      }      private void initevent() {         mbtdown.setonclicklistener(monclicklistener);         mbtup.setonclicklistener(monclicklistener);     }      private void upscale() {         mcurrentscale += 1;         mtvtestzoom.animate().setduration(0).scalex(mcurrentscale).scaley(mcurrentscale).start();     }      private void downscale() {         mcurrentscale -= 1;         mtvtestzoom.animate().setduration(0).scalex(mcurrentscale).scaley(mcurrentscale).start();     }      private void settext() {         mtvtestzoom.settext(mcurrentscale + "");     } } 

this may happen because textview exceeds layout bounds of parent. overcome this, simple put android:clipchildren="false" in xml description of immediate parent of textview. may need parents too.

edit: upon testing code myself, found textview did disappear following log message:

e/openglrenderer: font size large fit in cache. width, height = 635, 1028 

this due possible issue in android hardware acceleration modules. 1 of ways avoid is:

mtvtestzoom.setlayertype(view.layer_type_software, null); 

this works , textview not disappear after size but, since disables hardware acceleration specific textview, may lose antialiasing.


Comments