First I used custom Listview, when i set some content on edit text and select value from dropdown list and after scrolling listview I lost my text view and edit text contents.
Then I use Recyclerview. but same happens with recyclerview too. I again lost contents from textview and edittext.
Are you talking about a FloatingActionButton, I guess?
It subclasses from ImageButton, so was not likely designed with text in mind, but rather, an image. An ImageButton in turn is also an ImageView.
Other Peoples' Solutions
So, you could look up how people have gone about adding text on top of those more common elements. Here are just a few topics on this very site, that came up quickly:
Adding text to ImageView in Android
how to set a text over an imageView?
How to show the text on a ImageButton?
My Ideas
One of several approaches that come to mind would be to implement the FloatingActionButton's onDraw(Canvas canvas) method, and then call drawText() on the Canvas object it receives.
Another idea is to arrange to have a TextView shown on top of the FloatingActionButton.
Or, alternately, don't use FloatingActionButton, but something that more readily accepts text.
Related
I'm trying to implement horizontal scrolling view and managed to actually implement it using this tutorial. Horizontal RecyclerView tutorial
It has it's problems on focusing but at least it works.
Depending use case i have about 2-8 different images to view.
Now my problem comes that my layout is looking like this.
Current layout There is also other fields which isn't included in image.
Now images comes to image field and text would come to text field.
I would like to make those so that when image is moved also text will move at text field but not another way around. When trying to move from the text field it doesn't do anything.
in that tutorial both text field and image field are in same layout but i have separated those and also have that third field which isn't part of the RecyclerView. And adding more to this mess i also have button and when pressing it will change to next image on image field at below layouts.
So what would be good approach to make this to work??
http://smstuebe.de/2016/06/12/mvvmcross-recycler-templates/
You must create an interface to return proper layout for each of your element. You must define all the type of layout in the template selector
In an Android app I have a background image and two buttons on it.
This is a partial screenshot:
I ask you for the best approach to click on the sinopsis button to show an overlay text, like this:
and also to click the fotos button to show an image slider, like this:
I don't want you to show me any code. I only need recommendations to know what kind of layouts or overlay views I should use to obtain the shown behaviours.
Thank you.
A simple TextView is enough. A TextView can have a background, translucent as in your case, or gradients, etc., and padding. You can fill it with Spanned Text so you could use hyperlinks, bold, colors, etc.. If you need scrolling, TextView also supports scrolling out of the box, but it'd be better to put it inside a ScrollView because the scroll will be smoother. In any case you don't need additional layouts.
You can just use a container layout (like LinearLayout. RelativeLayout, ScrollView, etc.. depending on what you want) and specify that to have a background image and then specify your drawable. You can then use TextView to display text. Don't forget though that you will have to create custom TextViews to achieve your design.
TextView can have transparent background and so, you can get the overlay effect.
I created a scrollable custom ViewGroup which has several >200 EditTexts in it (not all of them are shown at the same time - I am using a recycler). The problem I am having is that the scrolling is very slow.
Interestingly, I don't have the problem if I do one of the following
1) disable the editText [editText.setEnabled(false)]
or
2) If I change the view from EditText to TextView
Any ideas on what the issue could be?
EditText is huge. Take a look especially at all those methods it inherits.
Why don't you try using just one EditText with 199 custom TextViews or a large grid of rectangles drawn within a Canvas? You could always customize your TextViews (or your drawn grid of rectangles) to make them look like edit boxes, but only use one EditText for the cell that has the focus itself.
That's even how Excel works for some of the functionality it has. It can edit a cell directly (yes), but it also has a static cell on the upper left of the Excel spreadsheet to show you the content of a formula (that may already be rendered as a view within the focused cell itself). You could do something similar yourself. You could extend an EditText to do all the hard stuff, like auto-complete, etc, but you could just draw the text inside the rectangle that has focus (or insert it inside the particular TextView that has focus).
Take a look at this example:
https://github.com/dennis-sheil/android-spreadsheet
He seems to be using mostly TextViews (although TextViews are heavy too, I'm starting to think that the Canvas may be better for something like this, and that everything could be simulated with the drawing method, by everything I mean the blinking cursor, the highlighting of the cell, the character by character typing, etc). With the Canvas at least, you can easily tell it what part needs to be drawn, and what part is off the screen and doesn't need to be drawn, so you're less likely to get into memory problems.
It can be issue with focusing the EditText during the scroll or you create too much objects and it is slow. Use ListView with EditText. Recycle views using viewHolder pattern. It will be smooth but I'm not sure if it is what you are looking for.
I would like show my text messages like this in picture that i have attached. Please give me some hints on that...
Sample text that i like to have:
First, I would create a small empty speech balloon as a 9-patch. This will be used as your TextView background and will expand as necessary to encompass the text. I guess you'll need to create one for every color you intend to use unless someone can tell me how to add color to such a thing.
Next, I would create a layout.xml file that contains some sort of container widget (LinearLayout or RelativeLayout probably) that holds a single TextView that occupies the left half of the container. Make another that puts the TextView in the right half.
Inside the container, put a TextView that uses the above-mentioned 9-patch image as the background.
Then, I would use a ListView for the overall container for your text messages. Construct an Adapter subclass that manages your list of text messages and uses a LayoutInflator to expand the above-mentioned layout.xml files to return the Views to be displayed by the ListView.
That's how I would do it anyway. Implementation details are left as an exercise for the reader.
This one bothers me for quite a while. I have an app where the user paints some objects with fingers. One is supposed to be a Text Box, a rectangular where the user can input text, like the one word provides (http://www.techrepublic.com/i/tr/cms/contentPics/r00319991202jod05_01.gif)
I do not need the text to be painted dynamically, I launch another activity where the user adds text and I catch the text on activity result. But I need the user to be able to reshape the object and it should handle all the cases like:
i. Box too narrow for the text -> get the last words to another line
ii. Box too narrow for some single words -> split the words
I want to handle this exactly like word text box handles it. I thought it could me by dynamically making a textView, but it seems impossible. I posted a question here Android - create TextView (or EditText) programmatically and set it in a specific place on the screen giving coordinates (mostly about textView) but I had no luck, drawTextOnPath can work for i but it is very hard to implement ii and show text in a smooth way.
I know we are not supposed to ask the same thing twice, but I do it to explain in a new way what I need, which leads to a different question. Thanks to everybody in advance.
Moving the Text around can be done easily by dragging the view in onTouchEvent.
Scaling the text can be done using two finger gesture. Just like the zoom feature in Webview. You should increase the textsize of the TextView on zoom-in and decrease on zoom-out.
Update:
Resize the TextView itself when two finger gesture is on. That will automatically re-flow the text appropriately. TextView can be resized by calling setHeight and setWidth.
Declare a LinearLayout with TextView as the only child.
Inflate this layout when needed and set the margins for the textview to position it appropriately.
When resizing just change the height and width of the textview.