Text inside button too big autosize? - java

The problem I am having is when changing localisation on the application the character length for some words is longer than the previous language therefore there are sizing issues with the buttons as they were initially made just for English.
English Locale Screenshot
Spanish Locale Screenshot
I know I am able to add android:maxLines="1" but this wouldn't solve my issue as the text is too large. I tried using a textview auto sizer for the text size but this hasn't solved the issue.
Does anyone have suggestions?

Thanks to #AdeelTurk for providing this answer. I was able to use autofittextview with my buttons but it was complex here is an example of how I used it with a LinearLayout which usually don't work with this API.

Related

How to customize FlowTextView for RTL?

I'm using "Flow Text View" to wrap my text around a picture.
But them problem is, I'm using Persian language so I have to set text direction to "RTL" but have no idea how to do it for the Flow Text View.
Here is a picture of how my texts get while direction is LTR...
I hope to help me how to set direction to rtl, I will provide any code you need and I will answer immediately.

Handling characters width in language conversion java swing application

I am working on a swing application which is currently in English.
Now I have to convert it in different languages like Russian, French etc.
The problem is that I have given size to components according to English, and I am stuck in handling characters in conversion.
For example "Hi" is written in 10 characters in some other language.
I cannot change component size. I want to know that what are the ways to do this?
I was looking for something that can change font size to fit the text in the components.
Thanks in advance.
All the commentators already posted the answer. Somehow I'd also like this question to be marked as answered/closed.
So my recommendation is to take a closer look at Layout Managers that calculate a component's screen size on behalf of you. You just specify rules like 'this is left of', or 'that component shall take the main space'. This way it is extremely easy to replace component texts and still have a meaningful screen.
To learn about Layout Managers, follow the fine manual given at https://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html

In Android how can I show a very long text (190 words), is there any idea better then textview?

I have a long text, about almost 1000 character including spaces (190 words). I tried to show that on a large textview, but it wasn't that great, didn't look pro, so is there any other idea?
Thanks for helping, and for trying to help.
What about using a WebView and pull the data from your resources? The data you load into a webview can come from anywhere, including a local file.
http://developer.android.com/resources/articles/using-webviews.html
wrap the text view in a ScrollView, then it doesn't matter how long your text is.

Android: Adjusting EditText font size to fit text to one line

I am making an app that has two EditText views, txtOne which is used for input, and txtTwo which is used for output. txtOne is editable, and txtTwo is not.
I am looking for a simple way to scale the font size of the text in these two views so that it always fits within the view without wrapping to a new line.
I have found a few implementations of this using custom views extending TextView, but they aren't fit for an EditText view, or use android.graphics.Paint, which is not what I am looking for.
Is there any way to check to see when text in an EditText view is wrapping? If so, then it would be easy enough to do something like:
if(txtOne.isWrappingText()) {
txtOne.setTextSize(txtOne.getTextSize() - 2);
}
Does anyone know of any way to detect this or an alternative solution?
I deleted my post
Basically the suggested code contained a TextWatcher for the EditText, this helped to answer the question. But the code itself was just wrong (I tested it meanwhile).
I suggest to read this question and answers because they adress the very same issue...

Android Development: Line Spacing With Line Numbering

In my app I have line numbers to the left of an EditText - everything is great so far, the line numbers are perfectly aligned with the lines of the EditText.
The problem is, if the user changes the text size of the EditText the line numbers aren't aligned properly. So I've added code so when the text size of the EditText is changed, the line numbers text size is changed too; but that causes another problem: if the user picks a big text size, the line numbers hog all the space, so there's barely any room to write in the EditText.
The only solution would be to set line spacing. So I eventually came across the setLineSpacing() function, and have tried using it based off tutorials but I don't understand how it works and can't get it aligned with the EditText's lines.
Can someone help me understand how to use it, or suggest a different way of getting each line in the line numbers TextView aligned with the EditText's lines?
Sorry if this is confusing, I'm not very good at explaining things well sigh.
Thanks,
Alex.
I faced a similar situation in the past, in which the EditText's size was limited. It was decided that the max font size that can be chosen should be limited to a value in which the visual appearance does not look ugly. I feel it is useless to plug cases that can occur but don't make sense. It is better to block such cases. Perhaps you can think along these lines.
HTH,
Akshay

Categories

Resources