I got the following recycler view, on the view item there are 5 checkboxes. How could I align the checkboxes inside the recycler view items with the TextView dates on the fragment..?
I tried using the same padding, but different dates got different sizes, as well as phones, so it doesnt display a correct alignment on all instances.. Is there a better way? I would appreciate any kind of indication, this is the last problem so I can publish the application.
You can achieve this in a simple way. Take all the textViews of your fragment inside a linear layout group. And keep the layout_weight similar. Thus the textViews will be equidistant.
Similarly, take the checkboxes in a LinearLayout view group. And keep the layout_weight similar. Thus the textViews will be equidistant.
Ps- check the padding and margin of the items, and adjust accordingly.
Related
I need to show images in horizontal RecyclerView, and this RecyclerView is inside a row of RecyclerView. Now sometimes I receive 2 or 3 images and sometimes more that can fit in its width. So, i want it to be Scrollable when there are more items then its width and when it lists few items then i want empty area to be clickable as well. How can i achieve this behavior?
The problem i am having is concerned in first row where the area need to be clickable is not in my control.
I know, This is old question. But I was stumbled upon a similar scenario.
Place the recycler view inside card view (card view is actually a frame layout) and set the recycler view width to wrap_content instead of match_parent. and the card view (parent of the recycler) width to match_parent. This will give you the expected result.
The card view is required, if you want to have the elevated cards for wrapping the recycler view. Otherwise any ViewGroup (like LinearLayout,Framelayout) should work.
You'll need to add a custom GridlayoutManager. Check this https://gist.github.com/ArthurSav/5f80e19d9ba6d562fbd5
from Arthur's Answer
I wanted to implement fastScroll like the one that is supported by ListView, but in a Relative Layout which has a large number of views, aligned vertically below each other. There are several different type of views so I can't use a list view.
I'm able to modify the thumb drawable for the scrollbar, but unable to make it work as a fastscrollbar.
is it possible to achieve it?
Do NOT implement list view on relative, linear or any other layout. You will run out of memory very fast.
You can have list view with different types of item views. It's called heterogenous list view.
Take a look here:
https://github.com/codepath/android_guides/wiki/Implementing-a-Heterogenous-ListView
and here:
https://stackoverflow.com/a/4777306/1535436
I have an Activity which is displaying an assortment of details about a particular widget. There is an image, a TextView for a description, some common stats in TextViews, and then a
variable sized list of categorised items, from 1 to hundreds.
Quick wireframe: http://i.imgur.com/Z4kY6Ky.png
My first assumption was to use a ScrollLayout containing all of these elements: ImageView, TextViews, ExtendableListView, which works only if I specify a height for the ExtendableListView. Since the height is variable this is not a solution. I'm also now aware it's not recommended to use ListViews inside ScrollLayouts.
So I'm stuck. Can anyone point me toward the best way to achieve this kind of layout?
Just put expandable list view as main component, and then put the header into the list. addHeaderView()
How to create this below view.
1)using listview or
2)inflating custom view in scrollview.
This is not only problem.
If list view then how to overlap the rows.
Each row have different color and that will come from api webservice.
In listview, at each row i have problem with red part which i have marked in second image.
even each row background is different and that same color will appear in below row.
How to do texture effect in listview?
The issue breaks to many things:
How to draw overlapping views?
I would try setting negative values for vertical paddings, but it's a wild guess. Also, you can just divide the graphics and draw views as rectangles containing view N and some parts of the N+1th view.
What about non-rectangular hit area?
You can manually detect clicks using color picking, shapes, or just simplify the view's clickable area to a rectangle.
What about visibility detection?
ListView shows only views, which are visible. I'm not sure, but most likely it won't work with negative paddings or similar hacks.
Personally I would write a custom view with ListView-like adapter and dynamic row loading.
I have try a many ways, and the best and fastest is simple set negative divider to listview like so:
android:dividerHeight="-100dp"
i'm trying to layout a fairly basic screen. it's just a details view screen after a list item click.
initially i'm looking to acheive a side by side stacked label value type of screen.
for example, where to the left of colon is static text and to the right of colon being dynamic values based on row clicked.
first name: john
last name: doe
last login date: yesterday
additional info: blah
i've started with a relative layout with a bunch of text views in it all positioned accordingly to acheive something like what i was looking for.
The problem arises when the dynamic data being displayed grows and stretches its enclosing text view. Of course the static labels don't grow and everything gets mis aligned...
I'm wondering if there is a different way of tackling this sort of layout...
i was shying away from stacking a bunch of horizontal linear layouts inside a vertical linear layout.
is table layout the way to go? i've read that "they usually aren’t the best tool for doing so, as they are derived from LinearLayout and not the most efficient of layout controls".
Yes there is. Use a listview with a layout predefined in xml. Use a simplelistadapter and pass it the dataset that you want to populate it with.
Edit
Here is a great tutorial:
http://www.vogella.com/articles/AndroidListView/article.html
For a simple form like you want to create I'd suggest using a TableLayout. It is simple to use. As you said the alternative to a TableLayout would be horizontal LinearLayouts in a parent vertical LinearLayout. Using a TableLayout will also automatically align the right side dynamic content for you. Everything on the right side will be treated as a column so if one resizes, they all resize to match.
In your particular scenario I would believe that the TableLayout would work well (although I have also heard similar issues of efficiency/performance). As long as the entire Viewgroup of this Activity isn't complex, I don't think the performance will be too noticeable.
If you are attempting to make the RelativeLayout version work, perhaps you can try this: Have all of your static labels are aligned to the left using android:layout_alignParentLeft and have each aligned to the top of the dynamic TextView they are corresponding to using android:layout_alignTop. This should keep the static TextViews aligned to the left while aligned to the dynamic view relative to it.
Now that those views are aligned, we can horizontally align the dynamic views to the longest static TextView using android:layout_toRightOf. From there, all the remaining dynamic views can also android:layout_alignLeft to this anchor dynamic TextView, or also align to the longest static TextView in the same manner that the anchor was. This solves the horizontal alignment of all the dynamic TextViews.
Finally, we can set that each dynamic TextView falls under the next, since the dynamic TextViews are our determining our vertical location within this RelativeLayout. Each view can use android:layout_alignBelow to chain the fields to align vertically.
I believe this should work for you and I can edit this post later in the day if you would like a sample of code.