Horizontal categories view - android

I have a list of categories. I'd like to add them in a horizontal scroll type view. But inturn i also want that the list contains only image and text of that category. And when i slide, it should directly come to an object of the list, it should not lie somewhere in the middle.
One object will almost cover the
How should i do implement that?

Related

How to make the second item of recyclerView visible 20% of the view

I have a CustomView that is a LinearLayout where it contains
TextView
RecyclerView
TheRecyclerViewItem
That's because I need to do something like this :
The first picture it works fine, but when trying to populate the list with more items, it gets the size of the Item and I'd like to make it a bit smaller so I can see in the screen the second item, otherwise the list only have visible one item at once, and that's normal because I'm using the same view for the item of recycler view than my first image, but I didn't want to duplicate layout, if that's the only solution I'll do it, but I'm trying to figure it out a "better" solution than duplicating and make it a different width.

Creating a customized list of custom views

I want to create a list like seen in the picture below and was wondering which one of androids controls would be the best option to do so?
For every row in the list I could use a custom view that has max-Val and current-Val, then draw a rectangle based on that.
But for the list, the headings, and the today indicator: What control should I use here?
RecyclerView is probably the way to go.
Define different view types for
the actual header,
the section headers, and
the list items
Setting it up like that will get you the whole screen except the 'Today' marker.
To add that marker you need to draw on top of the views in the recyclerview. There are 2 options
Just add another view on top of the recyclerview where you draw the text and line, which is possible but not really the cleanest approach, or
use a RecyclerView.ItemDecoration with which you draw the 'Today' text on top of the first item after the header, and decorate (draw over) every subsequent view beneath with the vertical line.

How to display one item at a time in a list in an Android Activity

I am new the Android development (3 weeks).
I'd like to create an Activity that allows the user to scroll through a list of items. I'd like only one item to occupy the width/height of the screen at any given time. At the same time, I'd like for the items to be able to scroll smoothly (up/down), similarly to facebook/instagram. During run-time, items will be pushed on top of the stack/list (like a news feed in FB).
What is the best way to accomplish this? What are the pros/cons between using a ListView, LinearLayout (Vertical) items, a List of Buttons added on top of one another? Or should I use Fragments that display on top of one another? How would I implement the ability to display only one item at a given moment?
The answer is to use a ViewPager: http://developer.android.com/reference/android/support/v4/view/ViewPager.html
By default, the motion is horizontal, but there are examples that show how to make it vertical.

Adding More than one item in the list view row and navigate them

I want to make the following layout in android. (Image Attached)
There is a list view and each item in the list view can has as many sub items. (One is visible in one row at a particular time), if a person wants to see further items in a particular row, then he has to use arrows provided on the left and right side of the item in the list view. (Image Attached)
On the arrow click, there should be a pager swiping type view and the next layout should come in the row.
I have tried so many approaches to do the same but have been stuck somewhere and have not been able to do the same yet:
Here I have tried all these :
1st Try
2nd Try
3rd Try
4th Try
Can anyone please tell me how to do the same functionality as shown in the figure attached and discussed above
Alright.
Try this, this should work.
Solution 1:
Have Horizontal Scroll view as child in listview, so basically you have s child now with horizontal scroll ability
Add as many as children you want to this scroll views, you can easily adjust layout of childs within scroll view to display.
Solution 2:
Have a ViewFlipper as a child withing listview
Perform the same thing as above, add as many child you want within this flipper
With flipper you get easy hastle free option like which child you want to display by default withing flipper.
Hope it help.

How to set a view to NOT scroll with scrollview in Java

is it possible to programmically force a View inside a ScrollView NOT to scroll?
Like the alphabetic titles in the contacts list. The 'A' bar doesn't scroll when the user scrolls through the list of all contacts whose first names start with 'A'. When the user scrolls till the end of 'A', 'B' bar simply scrolls up from the bottom of ScrollView, finally reaplacing 'A' at the top and staying there.
My description is kind of abstract, hope you understand.
Also thanks in advance.
The contacts list uses the ListView and not the ScrollView. One way I think it can be done is to have a fixed header at the top. You can change its content depending on what is being displayed on the screen.
Attach a OnScrollListener to ListView. You will get the view with the first visible position in onScroll. Then change the content of the header according to the content in the view.
You don't need to add a header in your ListView for the first section in your list as it will be already handled in your ScrollListener. Keep the style for the header rows and the view at the top the same and you will have the illusion for the fixed header.
I think you need a combination of the "static text" approach with "section headers" within the ScrollView: the list should contain disabled/non-clickable items with the letters "A", "B", etc. When a section header scrolls above the top of the view, change the contents of the static TextView above the ScrollView to the contents of the header. I.e., when the "B" header item scrolls out of view, the TextView now contains "B".
Of course, the tough part will be detecting when a "section header" scrolls off the top, or comes into view when scrolling in the opposite direction.
For bonus points, use a "push up" Animation in the TextView when it's contents change to make it look like the list item is rolling into the TextView. (There is an example of this Animation in the API Demos app in the SDK in "...\view\Animation2.java").
UPDATE: after further review... here is some classes, etc. related towards making this work (it was a fun exercise for me!):
android.widget.AbsListView.OnScrollListener interface to see how to detect scrolling events. You'll need to keep track of the previous "top of view" position to determine which direction you are scrolling (to pick the slide-up or -down animation).
The Animation I listed above is not really what you want -- better off to look at the android.widget.TextSwitcher class and the push*.xml files in the SDK/android-X/data/res/anim directory.
You'll certainly need your own adapter subclass to inject section views into the list: getView(...) can set the row view's properties (bkgnd, text style, etc.) differently if the row is a section header or not. Re-use this code in your TextSwitcher view factory to populate the static TextView/Switcher above the list.
Have fun...!
As mentioned earlier you need a ListView. For an effect similar to that in the People app in Android 4+ I have used this excellent library (free and open source).

Categories

Resources