Now I need to decide what widgets to use. There are a brief text description from an SQLite database and an image from an SD card or from the Internet on the screen.
I think that it would be better to use a single WebView to show the content than a TextView, an ImageView, and a TextView again. Are there any better ideas?
Here is a picture I created on Lucidchart.
Using WebView is not a good idea, Put the three components within a RelativeLayout and in a ScrollBar so that you can extend the elements without worrying about the size of the text as well as image size. And also webView will not render text perfectly.
Either option is fine. If the text in the database is in html format, you should use a webview. If not, you can use two textviews and one imageview.
With the WebView: you can justify the text, but it will not be a very clean solution if you want to resize the image for different screen sizes/resolutions.
Related
I have a txt file which is around 2MB. I need to display it in android. I have tried out WebView and it takes around 5 seconds to load and display the file. Is there any way I can get it rendered faster? Moreover, I dont want to load all the text at the start. Something like a scrollbar which displays elements efficiently is what I require. I need not stick to WebView alone, but can choose to show it using any efficient way.
You can divide your text by paragraphs and use listview. show each paragraph of text in one item.
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 )
Very general question: I have multiple widgets in a ScrollView Android app. A standard ScrollView, mobile can show say 720 lines and user can scroll down then back up going thru multiple widgets (text panes, buttons etc). Problem is that I want to add a WebView that will display an HTML table; the height of this HTML table will be variable size.
Is there a way to change the height of the WebView based on the size of the HTML table it should display?
Yes, you can get a reference to the WebView, then set the height of it, with the setHeight attribute.
Maybe you would be better off letting the container take care of that for you, and set the attribute to "wrap_content".
I guess, you need to calc web-view content size (here and here and enter link description here), than set webview size to content fits (maybe here). In that way you should have only scrollview scrolling.
Good luck
what I want is exactly what ThinkFree Office pdf viewer Reading View does.
I have a bunch of text and I want to be able to adjust it's size (users can choose from different zooms) and the text should paginate accordingly, I want it to wrap the screen, so that the user doesn't have to 'move' the screen, the rest of the text will show on the next page.
I know how pagination works, but how can I determine how much text has fitted the screen, so I know what to show on the next page?
Thank you
I mean't that you could adapt the codebase there by turning off the resizing part and just using it to paginate. It definitely would need work to make it fit this problem. Did you find a solution?
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.