Im kind of new to android programming with java, and theres a small thing which i want to clarify, i have no idea what this is called either and the Question topic name might not match to what im asking here so sorry about that :P
I want to dynamically create panels which will get filled with a text, and a button when the user clicks the small plus sign (ref image)
Can anyone point me to a tutorial becouse i dont know what this is called, and any small examples would help as well
]1
For something really simple based off your design, I might recommend using a ListView as the learning curve is easier. However, the RecyclerView is optimized for performance and can be easier to build a lot more crazy scrollable layouts such as Instagram.
Recyclerview Tutorial in Kotlin by Ray Wanderlich -
https://www.raywenderlich.com/170075/android-recyclerview-tutorial-kotlin
Android Documentation - Recyclerview -
https://developer.android.com/reference/android/support/v7/widget/RecyclerView.html
https://developer.android.com/guide/topics/ui/layout/recyclerview.html
Android Documentation - Listview -
https://developer.android.com/reference/android/widget/ListView.html
https://developer.android.com/guide/topics/ui/layout/listview.html
Vogell ListView Tutorial -
http://www.vogella.com/tutorials/AndroidListView/article.html
Related
I have a RecyclerView with the implementation of ItemTouchHelper. I am dragging and sorting the items in RecyclerView using ItemTouchHelper.
Also I am performing different actions on different direction of swipe. If user goes from left to right (Swipe) I just Deactivate status of item. If he perform right to left swipe I activate the relevant item.
What I want:
But now here comes the change, What I want is that I need to show some icons after I perform right or left swipe. And By clicking on those icons/buttons I want to perform action then.
Problem:
Problem is as I told you I have implementation of ItemTouchHelper, then how I am doing to perform what I wanted (as described above)
How to solve this? I have seen many libraries but they have limitations, also as the app has very much things going and there are some more implementations on RecyclerView used in our app, so I really do not want to risk the rest of implementations for the sake of this..
UPDATE 1:
To clear my question more I am going to add on more. Right now My implementation is something like this. But this is not what I want. I want to show swipe menu for any type of swipe I mean either it is left or right I want to show some icons on left and right side of item
You can take iOS swipe menu as an example (see here). I want exactly same behavior in android.
You're asking the impossible: suggest a library that doesn't exist (as you have already found out).
You're asking people to also find a solution for a problem you only briefly describe. You're not providing any code whatsoever, nor any specific issue you're facing when trying to come up with a solution; you're essentially expecting magic to happen.
How can you make this better?
Provide something like: "I'm attempting to implement a swipe solution for a recycler view's row; when I try to do YYYY is happening instead. Hhere's my piece of code where I do , calculated like this , am I missing something?"
Anyway...
You claim to be using an ItemTouchHelper already, so, if you look at how a very basic one works, you'll notice that the helper will ultimately draw on the canvas directly via:
#Override
public void onChildDraw(
final Canvas canvas,
final RecyclerView recyclerView,
final RecyclerView.ViewHolder viewHolder,
final float deltaX,
final float deltaY,
final int actionState,
final boolean isCurrentlyActive) {
This is derived from the platform ItemTouchHelper.SimpleCallback. So...
If you want to implement your solutions, you'll need to implement it there to do things like stop dragging, draw the content (icons), etc.
It's not a trivial solution and getting the whole thing right is difficult; more so if you introduce "some more implementations on RecyclerView".
I hope this answer points you in the right direction, and that your next related question is more about what you've tried (and failed) to do, than a "please do this for me" scenario. (If your intentions weren't those, please apologize, but you spent 5 minutes typing this question and it would take hours/days to implement this, so set your expectations this time).
Finally, when I wrote this, I realized most people wanted iOS swipe behavior; unfortunately, said behavior is not pre-implemented (like on iOS) on Android and you have to deal with it yourself; it's not impossible nor the most difficult task on earth to do on Android, but will give you a few headaches if you're hacking RecyclerView too much.
UPDATE
You've realized now, that ItemTouchHelper has a problem. It draws on the Canvas directly, so it has no knowledge of a Layout, View, Margin, etc. These are all things that live outside the realm of the touch helper. The helper is given a canvas, and drawing capabilities and that's it.
Where does this canvas size come from?
Well, it's calculated during the layout/measure pass(es) for the RecyclerView and its views.
How do I then stop dragging "at exactly the center of the screen" then?
Pass the values to your Helper; remember that the responsibility of calculating where the middle of the screen is, is not in the TouchHelper's contract; but your Activity/Fragment does know this. Provide the information the Touch Helper needs to perform the things you want it to perform.
Revert "back" to the original position, means knowledge of what the initial state was, etc. All this information is known by the RecyclerView and beyond, not the TouchHelper.
So you'd need to measure your layouts, save some values, pass them to the touchhelper so it can operate, etc.
As you can see, the full picture starts to become more and more complicated. My advice to you is:
Try to push this feature OUT as "the platform doesn't do it it will take time, it's not worth" (the worthiness and discoverability of swipe actions is dubious at best, but it's an ubiquitous action nowadays so you may have to do it regardless).
If you really have to do this, abstract things as much as you can, create all the classes/interfaces you think you can need, even if you end up with a "MiddleScreenCalculatorDelegate" kind of thing. It will be easier to fix later, but at least have each component do a very small subset of things.
Lastly, your item touch helper will have to calculate how much offset (delta) has the view been swiped already and stop when it reaches a known threshold.
Good luck :)
p.s.: I suggest you post a different question with specific issue(s) to get better help, this answer is very unhelpful as it is. :)
I have a question related to Android app UI implementation. The UI I want to implement is very similar to the Slideshare app UI, which I've attached below:
Apologies for the size of the image. But basically I want to implement a vertical list, and each item within the list is another horizontal list of sub-items.
My current plan of approach is implementing a vertical RecyclerView, and then implementing each item of the list as a horizontal RecyclerView (basically a 2-Dimensional RecyclerView).
Am I on the right track here? I apologise I cannot provide any code because I am still in the design phase. I do not want any code solutions but rather a guide or small tips as to how to approach implementing such UI.
Thank you for your time reading this question. Any tips would be highly appreciated!
You can use TwoWayView library to implement this scenario for bot horizontal and vertical listviews or you can use RecyclerView.
TwoWayView Library: https://github.com/lucasr/twoway-view/
TwoWayView Samples: https://github.com/lucasr/twoway-view/tree/master/sample
You can read a great tutorial about how to implement this on on this Github page.
You can take a look at VerticalHorizontalListView and twoway-view
and of course this link might be a help, which explains how to implement Dynamic Shelfview in Android.
I found this answer on SO :
Horizontal ScrollView in List View Item Android which explains the issue prefectly, you can take a look at that too. I hope this links help you ;)
I would like to know what the Android implementation is of this type of scrolling that you see in the Yahoo Weather App. Here is a video example:
http://www.youtube.com/watch?v=a-q_yetkpik
Any examples or ideas on how to implement this would sincerely help this poor lost soul!
Thank you
use that library https://github.com/xgc1986/ParallaxPagerLibrary, it's very easy to use, and it worked for me
demo
You should separate two different things here:
The horizontal scrolling
As you swipe your way through the viewpager, the background moves slower than the content does.
This effect can be achieved with the ParallaxPagerLibrary
The vertical scrolling
As you swipe up, the background image blurs away, making the "swiped up" content more visible to the user. This post explains it all and also provides a library.
But if you want it even better, someone wrote a simple "clone" of this weather app https://github.com/MoshDev/LikeYahooWeather
They customized ViewPager, the widget is called WeatherViewPager that it's unfortunately unavailable, looks like a ViewPager with a sort of parallax
You may take a look at https://play.google.com/store/apps/details?id=com.desarrollodroide.repos
it's a collection of usable opensource libraries
e.g. Utils->Paralloid or Utils->ParallaxScroll
I want to develop an android app, but I'm still not that great at using xml or the eclipse wysiwyg editor to make scalable and robust interfaces!
Below is a quick concept I drew up on word of what my main game screen will consist of:
I'm currently thinking a vertical linear frame first, with a frame that doesn't change for my important stats etc., then a frame in the middle which is switched by the buttons, but I'm stuck on how to implement this.
For the centre button screen, the map screen, I am hoping to add an image of a map which can be moved around, and somehow attach invisible button objects to points in this picture, maybe with an array of squares or something?
I understand this is a pretty open question and might be difficult to answer, but if you think you can help in anyway please do.
Thanks!
There is a log of possibilities, but you can use a LinearLayout with android:orientation="vertical" and include your stats in top. For the changing screens with buttons you can use a FragmentTabHost and create different Fragment for each of your views.
Check this example with a implementation.
Regarding the map, I think the easiest option is to use Google Maps Android API v2. Here is a example to use the maps v2 and a example of how to add markers to the map.
I'm curious to implement a balloon tip to show info of different UI elements in an activity. How can I achieve this? On some little effort put to this (correct me if I'm wrong please) using something like canvas rectF???
It sounds like you're looking to create tooltip text. This isn't built-in to the View classes in android, so you'll have to create them or use a library like GreenDroid. This has already been addressed, see the following:
android how to make Tooltip for TextView
Android "Tooltip"