How to visualize text in message field in android? - android

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.

Related

How to make RecyclerView with multiple ViewHolders so that one ViewHolder is also controlling another ViewHolders content

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

How can i create a layout that behaves like an edit text view

//still a learner :-)
I'm trying to create a layout that behaves like an edit text view, except I'm populating it with small xml layouts instead of text, these will be added dynamically eventually but for now I'm just using the include tag in xml to see how it reacts.
what I'm trying to achieve essentially is a keyboard that, instead of single characters, is made up of cards with a word and picture.
When a card is selected it should show up in a view, we'll call this the cardview. The cardview should display each card in the same way that text would be displayed in an edit text view, ie; each selected card should be displayed next to the last, and when it reaches the end of the cardview it should start placing the cards below, just like a long line of text in an edit text view.
everything I've tried has failed one of these conditions, the closest I can tell is a linear layout, this would of course place each card next to the last but doesn't respect the end of the view, the cards just keep going.
so my question is do I need to do some fancy programming to create this viewgroup to mimic an edit text view? off the top of my head maybe by measuring the screen size and creating a custom layout of some sort that allows X many cards before starting a new line, (and if so can anyone offer me a starting point?) or is there an easier way, something I've missed, by using a nested viewgroup or some kind of table layout?
any and all replies welcome, and thanks for your time

Textview and edit text loses contents from Listview and recyclerview

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.

Ideas how to build a screen with 100 Views added programatically

Right now I'm stuck how to manage to build a specific Activity in my app. I've added an image so I can explain my problem:
So first of all: all the content will be loaded from an API. "Static text" in my image means that I can define these parts in my activity.xml and don't have to do that in my Activity.java because these parts will be always the same for the screen (meaning the size of the elements, the content will be loaded from my API).
The green box should be horizontal scrollable or not depending how many boxes have to be shown here (1 to 3 possible).
The blue box will be generated in my Activity (in the end it should look like a table) and I want to define the layout of a single row in a separate xml (e.g. table_row.xml) so I could change it easily. This table can have up to 100 rows depending on how many are returned by the API.
So my problem right now is: Obviously this whole layout has to be scrollable so my first idea was to use ScrollView and a LinearLayout as child. But I read here on stackoverflow that the performance will be really poor if you use LinearLayout and add Views to it. So everyone recommended using a ListView for this part (meaning the blue box for my Activity). But that would mean only my blue box will be scrollable as you should not use a ListView in a ScrollView.
So my question is: How can I make this whole screen scrollable with a table dynamic in size without losing performance?
Put the first three layouts as ListView Header and make your blue box layout as the list view. By this you'll be able to scroll the complete View i.e. Blue Box, however the first three layouts will be static and won't scroll.

how to design this UI

I am trying to design a UI as like in an iPhone app. The image of the design is as follows
In the above image all the white boxes are of a list view. In those list view i am placing an image View and two set of text view. I have placed a overall custom list view and in that custom list view using relative layout i have place the image view and two text view.
now i want to draw a line between the two text view and when i click on the second text view i am moving to a new activity. At that time i want to show that only the second text view is been clicked.
Use a RelativeLayout:
The image android:layout_alignParenLeftt="true"
the first two textViews android:layout_toRightOf="#id/myimage",
the other textviews below the previous ones (e.g. android:layout_below="#id/author" and with a layout_width="fill_parent"
Check Romain Guy's blog post for a tutorial on a similar (simpler) setup: http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html
Check this http://www.androidsnippets.com/clickable-listview-items
The ClickableListAdapter bases on the
API-Demo-Example "Efficient List
Adapter". It was refactored to provide
a better reusability. Additionally,
you can connect OnClickListener and/or
OnLongClickListener to each View of
your list item. This allows you to
create complex interactive lists, or
simply using a customized checkbox
version.
I had implemented this in a project minus the image view. Heres a screenshot.

Categories

Resources