I wanna create a simple calculator. One from my goals its place in EditText field images with special math chars as like square root, pi... F.e. :
2/34*sqrt(121)
Here I want to place images instead of divide, multiply chars, sqrt string.
how I can do it?
Some more questions:
Does it actually need to be Editable i.e. user can type directly into it? If so how will it work? when they type '*' it will realize it and replace it with your png? Would it be acceptable if it didn't interrupt as they type but instead all at once when they are finished entering the entire line?
Best answer I have for now:
EditText doesn't support that by default. You'll likely have to create your own view that is some kind of mashup of EditText and LinearLayout that can hold ImageViews with your pngs. If it doesn't need to be editable by the user it is going to be easier because you can make your custom view a LinearLayout and add TextView's and ImageViews with the proper text and images set in them. If it does need to be editable it is going to a bigger challenge. You'll have to use a TextChangedListener to pull out each character as it is typed and replace it with an ImageView if need be. Seems to me like the hard part is going to be knowing where to position the ImageView and having the EditText know that you want it to pick back up with text on the other side of the Image. Im not sure how you'd go about that. Maybe the best solution is you have an EditText that they type into and then seperately you have your custom view as a display view. That way you don't have to worry about positioning images over the top of an EditText and correctly moving the cursor to right side of the image.
What I would suggest is looking into a freely available font that includes mathematical symbols (some quick searching turned up the StixFont project), then just add that font to your assets, and set it as your typeface. You'll still probably need a TextWatcher/TextChangedListener as Tim suggested (unless you're using your own keyboard to input the symbols) but this would get around the problem of trying to insert images into a text field, and would also keep the vector quality provided by fonts versus a raster image embedded into a text field.
Related
I am creating an app for users to hold the phone in a specific way - therefore one method i am testing is blurring an image depending on the phones position.
Now I want to let the user do a small task - write something to an Edittext and blur the text too --- sure I could display the textinput as textview on top of the image, but probably the users eyes are focused to the edittext and not the image/textview
So is there a possibility to blur the input within the edittext? An other possiblity would be to blur the complete view (combined with a lot of refactoring), but I would prefer the edittext solution..
Would be great if someone would be able to help me!
You can try and use the alpha property of it to reduce the opacity.
A similar answer that makes a custom TextView for it can also be seen here: https://stackoverflow.com/a/2904259/8118133
You can also look at adding a BlurMaskFilter if that does the job for you.
I am trying to have a custom EditText based on the background that i am using for. The Background image has some spaces between the entry areas so i need to have some space between the characters(kerning) to fit them right in. So for example after every character the user enters, i need to put 4 whitespace after that.
I couldn't find any solution for this on the net so far, some people suggested TextWatcher, but i couldn't manage to make it work as i want it too.
Can someone help me about it?
Thanks
I have you considered using a custom font? Some font types are made to stretch out or shrink or have empty spaces. With so many different fonts available online, you can definitely find something. You can also make your own with a software. It might be time consuming if you start the lettering from scratch. I'm not 100% sure if it'll fit exactly to your background, but it's idea that you can consider.
If it doesn't fit, I supposed you can always customized the background to fix your font too. Here's the code for those who might want to use custom fonts in their app too.
Typeface myfont = Typeface.createFromAsset(getAssets(),
"fonts/Blocks2.ttf");
myeditText.setTypeface(myfont);
The font is in the asset folder under another folder called fonts.
This question is related to How to change letter spacing in a Textview?
As shown at this issue: android format edittext to display spaces after every 4 characters a solution might be to insert spaces with Java code...
You need to use TextWatcher to achieve visual purpose spaces.
And use any simply split string by space logic to join it back or loop
through the entire string per character wise and eliminate (char) 32
from the string
As far as i know actual character spacing is not possible, though i'd love to use that myself as well.
Another option might be to use a custom font with the character spacing included.
I am trying to create a header navigation for my app. I want to get rid of spaces between the buttons, and as I understand it, I need to set images as the background.
My question is whether the images should contain the text on them, or be transparent, and I would just put the text on the buttons by the text field in the layout of that button?
Thanks!
You can have it both ways, but I'd recommend setting the text on the images it saves you space and allows more room for change in case you wanna change a word you dont have to edit the image.
And most importantly you let android auto scale you text to fit screen size( if you set to sp of course )
One of the problems i'm facing now, is displaying complex texts (English + Persian/Arabic).
The texts which have both English and Persian/Arabic letters, not display in correct order.
For solving this issue, I created a Bitmap Font library that draws these complex texts correctly. Now i want to convert all the texts in all of my program's widgets to their bitmap equivalent. For example, if i have a TextView in my program, i want to get it's text, convert it to a bitmap with my bitmap font library and finally replace it in the TextView. The problem is finding a general solution which can be applied to any widget that can display text, like ListView, EditText, Menus, ...
You can try looking at the source code for TextView and modify it to suite your needs (ie, whenever a user enters a character using the IME, capture the event and insert the correct bitmap character to your custom view...)
Have you seen Arabic Reshaper from all what I've understood it can be used to display correctly texts that contain both RTL (arabic) and LTR symbols.
You can use font library in c++ and render the correct font
though bit lengthy
I made a display, that will show the sum of purchase. It's a TextView with background image. I have a designed digits too. How can I set those digit images to that TextView or do I have to create some layout instead of simple TextView? If I need to create layout, can you add some code sample, how can I do it?
Here's an example what I want to achieve.
Regards,
evilone
As far as I know, your two options would be to create your own True/OpenTypeFont (setting the color of the text to yellow in xml most likely) or to code your own custom ViewGroup which will take a String and convert each character to the appropriate image.
If you're able to construct your own font, you can add a font folder inside your assets project folder, and put your font in it. It can then be loaded like this:
Typeface tf = Typeface.createFromAsset(myContext.getAssets(), "fonts/MyFont.ttf");
myTextView.setTypeface(tf);
This site has free fonts even for commercial use, http://www.fontsquirrel.com and I searched for led and found a font called radioland that looks good, though the numbers are at an angle. If you do use that site, I've found it's good to verify the font is indeed free to use with it's included license or a software and can open the font and view it's headers.
Install and use the National Instruments 7 Segment LED font. For the Pound symbol, you can make a tabular layout and put it in a corner.