In android L calculator app when you try too add more than ten digits
Text size changes with a cool animation. so Text/Font size goes smaller and you can fit more digits
How can I do that ?
[UPDATE]
As shown in this Video
Try these properties. Should be anyone from this.
android:translationX=""
android:translationY=""
android:transformPivotX=""
android:transformPivotY=""
android:scaleX=""
android:scaleY=""
for the Animation use this example :
TextView Animation Size
do it in the Callback onTextChanged which occurs when you Type a char in the View
Hope it helps.
also you can use the same Animation to EditText but use this Example for this :
EditText addTextChangeListener
Related
I have the following requirement.
Initially I want to show the textview half on the screen. This textview when pulled out/clicked should show a complete one.
I just want few hints as to how to get over such animation.
You must use a translation on the X axis animation.
This should give you enough to start working on it:
textview.setX(5000); //TODO: change to (current X + textview.witdh)
textview.animate().translationX(0).setDuration(1000).start();
I am working on Android textview,case is i have a specific height of textview,i want to adjust the text in the given textview height by adjusting the font size.If a text is of 10 charachers it will covers the whole height and if text is off 400 characters it will decreases the font to adjust in height of textview. I have tried auto text resize class but it does not getting the desire result.
You are looking for FontFit TextView. Check out here.
You just have to use it instaed of normal TextView like this..
TextView tv = new FontFitTextView(context);
Hope this helps
You can also write your own logic for that like
1- : Count no or character in side text watcher
2- : if no of character more then 10 then reduce the size of test using textsize method.
3- : the same logic if character more then 10 then reduce the size of test using textsize method.
or you can also put it on loop then i think you can achieve it also.
I was wondering about what is wrong with my layout.
Here is a screenshot.
Problem being that the text is being cut off in edit text boxes.
I suppose there is something wrong with the text's XY co-ordinates at the time of typing in those edit text boxes; the cursor blinks fine to me.
Here is the pastebin of my XML layout (not putting it here because its quite lengthy).
Any advice will be appreciated. Thanks
The text size of the text inside edittext is large for hardcoded 30dp height of edittext. You can either set edittext height to wrapcontent or reduce the textsize of edittext (10-14sp)so that it fits inside.
It is advised by android to set minimum height of clickable area to at least 48dp.
http://developer.android.com/design/style/metrics-grids.html
I have code:
Text infoText = new Text(560, 10, mFont, "this text is too long to be in one line", activity.getVertexBufferObjectManager());
How I can set this text width(for example 200px). When text will be longer than this width it should break line and write more in next line.
I can' t find any example for this. Is it possible in Andengine gles 2 ?
I was looking around in AndEngine's code to find a solution for your problem, and I think I've found it. The method splitLines in the FontUtils class seems to be what you need.
It's arguments are: the the text you're splitting, the font to measure widths with (The font you'll be using for the text), an object that extends List<CharSequence> to save the new lines in, the type of split (AutoWrap.WORDS to split by words) and the maximum width per line.
Here's a link to the example from the AndEngine examples
https://github.com/nicolasgramlich/AndEngineExamples/blob/GLES2/src/org/andengine/examples/TextBreakExample.java
that should do it for you
I have a layout and a button in it. In onCreate(), I calculate the size of layout and size of button dynamically. Now based on the size (width) of the button I want to set its TextSize. Initially the button textsize is set to 11, but if the button size increases, the text looks very small. So I need to increase the size of text also.
Is their any method/way where I can calcualte the size of text and check with that of the button size. Any ideas for appropriate method or logic to be applied.
NOTE : I want to change the textSize of button based on size of the button and not change buton size based on textSize.
Any help is highly appreciated.
If you get the paint for the button with getPaint() you can use measureText() with your text to get the width the text needs for a given setTextSize() setting. You may want to experiment with some spair space.
There is code using to concept for a different case in this question