Recycler view items take its width and can continue with new row - android

is there any way to make a design like this (image)
EXPLANATION:
List of items where item take its width if screen widths are not fit so continue in next row.
Item(2) starts after the item(1) and continues in the next row.
Items will be textviews
flexlayout has limit if item will not fully fit it make it in another row
Edit:
(Assume Case )
assume I have two texts and want to display them
for ex text1 = "Hello ", text2 = "Ahmed"
and screen width can fit 8 character
so UI should be
Hello A
hmed
[Actual Case]
here there are two texts , first with below background and second without this is final UI

A small example for assuming the case
input: Hello Ahmed
expected output :Hello A
hmed
You can store a list of strings into single string. Make text view height wrap content using Spanable string, you can have more control on text.

You can achieve that by adding android:scrollHorizontally="false" to the TextView xml that is displaying the text.
<TextView
.
.
.
android:scrollHorizontally="false" />

Related

How to make recyclerview hight same as tallest item when multiline text present?

I am using recyclerview where item can have multiline text.the problem arise when one item has single line text and other has multiple lines of text.one item get bigger than other.
I want item height will be same as talles item.How i can achive this?
You can give fixed height to TextView. Like
android:layout_height="50dp"
Or you can set fix number of lines of TextView
android:lines="2"
This will help you inside your Textview tag in the listItem
android:maxLines="1"
android:marqueeRepeatLimit="4"
This will help text to scroll if its long engouh for one line

How can I draw text on a text view bottom up?

I need to draw text on a TextView in a bottom up fashion, i.e., draw the last line of the text first at the bottom, then the second last line of the text and so on. How can I do that?
I am trying to follow the solution given in this post - Paginating text in Android.
TextView draws the text top down. What I want to achieve is given a text, I would like the last line of the view filled first, then the second last line and so on, Hence filling the first line in the last iteration. I tried creating a Custom TextView and overriding its onDraw method, but nothing seems to work.
Create a custom textview. In the setText method, do some string manipulation. Basically rearranging the text in the string so that the first line I the new text string is the last line of the old text string. Pass the new text string to the super.setText
If it is not scrollable textview you can set android:gravity="bottom|left" or "bottom|right" if you want right alignment. With this method width and hight can't be wrap_content.

Make First line height in textview the same as other lines

I have a recyclerview with bunch of textview each as an item as you see in picture below. (Blue lines aren't really there, i added them so you can see each item separately) as you can see everything seems nice and user will not notice the text is separated.
The problem is when user increases the line space(a typical option in app) line height gets bigger except the first and last line of each item and the result seems like second picture.
My question is how to find appropriate padding to set to each item so every line height seen exactly the same?
BTW i can not use just one textview for many reason!
You can increase the divider height of your listview according to linespacing height.
Or you can set an invisible view at the bottom of every row item and increase the height of this view according to linespacing height.
Or you can set padding at the bottom of every row item and increase the value of this padding according to linespacing height.
just add some padding to the parent of your textview in the layout file of your list item .
for example the layout with linearlayout would be like :
<LinearLayout ........
paddingTop=15dp>
<TextView
..........>
</TextView>
</LinearLayout>
and you could adjust the padding dynamically if you want.

UiAutomator Accessing a child with limited information

I have a list of view that are built dynamically so they all have they exact same Resource id, and no description. The only way I can distinguish the difference between them is a text that is in the same parent. I am thinking the only way would be to do it like this:
Child >> parent >> child
As you can see above, I can get the child MILES or CALORIES. I need to get the text from the large numbers.
The text from the large numbers views can be obtained. Let's suppose the layout is:
1. RelativeLayout
0. Text View -> MILES
1. Text View -> 0.50
2. RelativeLayout
0. Text View -> CALORIES
1. Text View -> 100
UiCollection resultsPage = new UiCollection(
new UiSelector().className(android.widget.ListView.class.getName()));
UiObject resultLayout = resultsPage
.getChildByText(new UiSelector()
.className(android.widget.RelativeLayout.class
.getName()), text); //where text can be MILES or CALORIES
UiObject score = resultLayout.getChild(new UiSelector()
.resourceId(the resource id for the large text));
return (String) score.getText();
The idea is to isolate the two Relative layouts and search for the text within them, not the whole GUI.
You can use uiautomatorviewer to look at the GUI layout. Maybe you could update the question with the detailed layout.
I could use that in order to give a more accurate answer.

Create animation for text field

I need to create an animation in Android. I have 3 TextViews placed in an LinearLayout. All I want to do is the text field must come on to the screen as though it has been pulled out from the left end of the screen. Something similar to a marquee, however the text field must come from left end of screen one character at a time to occupy the left end of screen.
you must textView set textview property in your xml layout android:ellipsize="marquee" and you oncreate() method to set textview like youtextview.setSelected(true); now your textview running with marquee effect perfectly work for me!
another way you can add dynamically textview in coding you can follow this code:
yourtextview.setEllipsize(TruncateAt.MARQUEE);
yourtextview.setSelected(true);

Categories

Resources