I need to create a RecyclerView with multiple ViewTypes. However, on some of the items, I need to display a Tooltip which should hover over the above row.
My requirement is:
In the above image, there are 4 items in the RecyclerView, and the tooltip in the lower row should overlap on top of the above row (or rows, as required). This tooltip would only be visible in some scenarios - when the lock icon is visible.
The problem is, if I add this tooltip as a TextView to the row_layout.xml, and control it's visibility programmatically, it increases the height of that row and does not overlap onto the above layout.
How can I get this view to "hover" over the above rows without displacing them?
If you require code, I can edit this question and post the code too (but I think it might not be necessary here).
You can make use of Android Tooltips library.
Simple to use customizable Android Tooltips library based on PopupWindow. This Tooltips does not require any custom layout. It works as PopupWindow.
dependencies {
compile 'com.github.vihtarb:tooltip:0.1.9'
}
usage:
Tooltip tooltip = new Tooltip.Builder(anchorView)
.setText("Hello tooltip")
.show();
Dont know if it will work for recycler view ,but for list view you can use quick action item, complete article is over here also look at these Libraries some of them may work for recyclerview
You could use this library Super Tooltips
It is simple to use and powerful.
Related
I have a RecyclerView that display the list of modifications per day for a document. Items are TextView with values like "Line 3 updated to ...", "Line 5 removed", etc. The ViewHolder handle 2 types of views :
Headers : which are the days. These are simple TextView too that are in bold, larger, etc.
Logs: that's what I was talking about : "Line 3 updated ...", etc.
What I would like is that each "day", with its corresponding logs are embedded inside a CardView. But a document can have huge number of modifications per day (>100). So programmatically creating a layout with a CardView as the root, calling 100 times addView() on it to add each logs and then passing this layout to the RecyclerView does not seems a good idea to me.
Is their any way to delimit between a "positionStart" and a "positionEnd" views that will be embedded inside a CardView? It seems to me that this isn't possible or by adding each TextView programmatically inside a CardView but it will then slow down the binding of the views and break the ViewHolder pattern. Am I right or is their a solution I didn't think about ?
You have 3 options to achieve this "grouped in a card" behavior.
(as mentioned) you create the layout yourself and put the whole thing into the recyclerview. This is probably the worst solution since it negates the idea of a recyclerview in the first place.
You just wrap each of your items in a CardView (and set the corner radius to 0dp).
On < 21 devices (I think) there will be some additional padding and every item will appear as its own card, but on higher API versions those cards will lie next to each other and just have some "seam" between them. The shadow on the corner is also a bit buggy, but this is probably the easiest and cheapest solution.
Alternatively you can also create a custom view that fixes the errors mentioned above (margins between and shadow) and use your own to wrap the views. (I believe this is what the Inbox app does if I recall correctly, which also features lists in cards.)
You use an ItemDecoration. For this approach you need a kind of stable setup of your dataset, but if its just the headers and logs, you can draw a shadow above the header, draw borders to the left and right of every item, and draw a shadow beneath the last log. This will also require some setup, and if you introduce further view types you will also have to modify this code (it's highly dependent on your data set)
The 1. method is probably the worst idea. It will work for small lists.
The 2. method can work, but you either will have to create your own custom view or live with a "bugged" version on lower api levels.
The 3. method is something I tried once for fun, and will work, but you will have some additional dependency between your data, your adapter, and your decoration. You can see an example of this decoration here on GitHub. It just draws a shadow around all of the items.
I understand the items that are visible to the user will be loaded when using GridView. Does this also applied when using GridLayout?
I currently working on laying out the applications' icon like the applications screen does. When user pressed the icon of the application they are allowed to arrange the icon in an unoccupied space.
At the moment, I don't know which widgets is preferred to use. If GridLayout behave the same as GridView, I would stick with that so no need to change the code.
If you want to be able to drag icons to rearrange them I would consider using GridLayout with RecyclerView. Take a look at Drag and Swipe with RecyclerView
Part Two: Handles, Grids, and Custom Animations.
If you are unfamiliar with RecyclerView and ItemTouchHelper then also look at Part One first
I am trying to create something like (very poorly created in paint) in the image below:
I have only 4 items, and it won't be more. the items contains two textviews. But when you click on an item, i want it to expand, (like item 2) to the bottom with three extra buttons. It would be really nice if there would be some nice expand animation. I don't want this list to be scrollabe, it just need to fits in my screen. And only one can be expanded.
I think there are two options, but maybe i am missing something.
1) Create an itemlayout.xml, containing an linearlayout or something containing the extra buttons, set to linearlayoutbuttoncontainer.setvisibility(View.GONE). And then build a switch, which closes the others than the clicked one, and set the visibility of the clicked item to visible. This would be fairly easy to build i guess, i don't foresee a lot of problems. But is it possible creating an animation or is there only a sudden screen change?
2) expandable listview, with the buttons in the expandable item. I know its possible to make only one item expanded, by rembering the expanded one and closing it again. But is it possible to make it like this, with the buttons in the expandable part? Actually i've never used an expandable view.
Anyone know what the best solution should be?
Thanks
I would recommend using an expandable list view for this, as your second option described. For this type of list you can use a expandable listview adapter, describded here:
http://developer.android.com/reference/android/widget/ExpandableListAdapter.html
This adapter has both a getGroupView(open/close items) and a getChildView method in which you can inflate your layouts, or manually set them up. If you have used ordinary listviews I'm sure this wont be a problem for you, since it's basically the same operations.
This means you should probably inflate your childViews with a LinearLayout containing three buttons. Then you have to implement functionality for your collapse/expand logics by keeping track of which item index is opened.
I did this tutorial when I first started out with exp.list views, I found it helpful:
http://android-adda.blogspot.se/2011/06/custom-expandable-listview.html
Good luck!
You gotta check this http://udinic.wordpress.com/2011/09/03/expanding-listview-items/ it works neat. If you got any more problems, do ask...
I have a gridview of images in android. When i click any item on it, i want to show a new set of items over it. This is the screen shot .
Can this be done using gridview? Also what should be the type of view which must come over the gridview? The background should become preferably faded.
I am not so sure if you can achieve the second view using a grid view. In the grid view AFAIK you don't have any option of specifying the location of the grid elements. It just arranges it from left to right and wraps around.
But here is how I would do it -
First view can be done using the grid
view, as you already know/done.
For the second view since you want the the first view to remain in the background, there are two ways to go about this -
First option
You can use a dialog, you can create your own custom dialog which has makes it translucent.
In this custom dialog you can add further elements like images.Custom dialog example. For details on how to make it translucent you can look the sample app in android sdk.
Second option -
Use a layoutInflater. Put all your views into it.
You can display one view on top of another using the visibility attribute of the view. Layout Inflater
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.