How to construct the RecyclerView for the following UI vertically? - java

The expected UI for my application should look like this:
I have thought about using a view pager but I cannot figure out how to change opacity of the next items or make the item in view to be centered and be elastic.
I have researched multiple open source GitHub repos and found two which seems similar to what I have approaching to do.
https://github.com/bloderxd/deck
https://github.com/Ramotion/garland-view-android
I do not know how to solve the problem of opacity or going to the next item using the next button in the UI (which was designed by me for a project).
So far, I could only create a simple XML representation of the UI without the view pager but I do not know what other libraries and views I need to implement to make it interactive and elastic like in the UI.
My request is how I could build the application level code for this UI. If there is any other obscurities in my questioning, feel free to comment and reach out because I am relatively new to this kind of development. Thank you.

Related

How to make side menu using browse fragment like netflix in android tv?

Attached screenshot of netflix app with left side menu I am able to develop a side menu with customized icon and header in it. I want, when the focus comes on header fragment it should expand on top of row fragment, that is not collapsing the row fragment, the same as Netflix and hotstar are doing. How can I achieve it?
unfortunately, the HeaderSupportFragment used in the BrowseSupportFragment is not configurable enough to achieve this kind of design. Leanback is great to build quickly and easily media browser app but when it comes to "complex" design, it's easier to use custom component.
The major difference also here, is that the left menu of the BrowseSupportFragment show each rows header name displayed in the screen (that's why it's called HeaderSupportFragment). Here you want to show different entries like search, home, settings, etc.
To make this kind of view, I would suggest creating your own custom view and use a basic Fragment. I followed this tutorial which can be useful to handle menu open/close animation (I mixed it with a ConstraintLayout to simplify the animation and I made the menu overlap the rest of the screen instead of moving everything.)
See the tutorial: https://medium.com/building-for-android-tv/building-for-android-tv-episode-3-381e041dfec7

Android: Yahoo Weather App Horizontal Scroll-view Effect?

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

How to change app theme from ordinary "Blank Activity" to "Master/Detail Flow"

I have an application that works on the basic theme "Blank Activity" and what i would like to do is to change it to a "Master/Detail Flow" theme. I do know that this will make my application work on android SDK 11 + (android 3.0 Honeycomb +), that is OK with me. The issue is i don't know where to start from, what are the basic steps to make this BIG conversion? I couldn't find any example to help me out with this issue. What should i be looking for. i am sure this has been done, can you at least please give me some pointer on how to do this?
my Application is not that complicated it uses activities, async tasks, DB, custom lists,... it is very basic. I use the custom list to display data and when i click on it it displays much more details, so I thought what better way to do this in a more professorial matter than the "Master/Detail Flow". If you have any tutorial regarding the "Master/Detail Flow" that you can hook me up with that might help.
I have an application that works on the basic theme "Blank Activity"
and what i would like to do is to change it to a Master/Detail Flow"
theme.
I think a change of the application flow would be more appropriate then a change of theme. Two obvious questions that would appear are why do you suddenly want to make this change and are sure your app makes sense in a master/detail flow? The answer would most likely be positive but you should answer them nonetheless.
I do know that this will make my application work on android SDK 11 +
(android 3.0 Honeycomb +), that is OK with me
I don't see why you're app couldn't run on versions below with the new master/detail stuff.
The issue is i don't know where to start from, what are the basic
steps to make this BIG conversion? I couldn't find any example to help
me out with this issue. What should i be looking for. i am sure this
has been done, can you at least please give me some pointer on how to
do this?
You haven't provided details about how is your app implemented. The change would revolve around fragments so a BIG question would be if the current single pane version is built using the fragments framework.
If your app is built using fragments then making the change shouldn't be too hard. You'd need to:
establish which parts(fragments) should be combined in an activity(from your old ones) to make the master/detail(when the space would allow it)
change the multi pane activity to accommodate the new fragment(s). This should be easy to do but it would depend on the size of the features exposed by each of those fragments.
modify the rest of the activities(for when the app will not run in the multi pane mode), this would be small changes as the activities would mainly remain as the current version
If your app isn't built using fragments, then what I said above still applies but you'd need to also actually make the required fragments wrapping whatever functionality your app has. This would most likely result in a big code refactoring.
Here is a tutorial about the Master/Detail template in Android - An Android Master/Detail Flow Tutorial.
As far as I understand your application is up and running - so I'm not sure whether it is worth it to try rewriting it, unless you are experiencing some problems of course. :)
In general the master/details flow requires the following steps:
Implement a ListFragment showing basic information of your items
Implement a Fragment showing detailed information about a particular item
Make an xml layout file for large devices (located in layout-sw600dp folder for example). In this layout you have to put both your fragments.
Write a general version of this layout file (i.e. file with the same name but located in the layout folder), which contains only the ListFragment.
Let your activity handle onItemClick event from the ListFragment. Each time an item is clicked, you have to check if the activity is showing both fragments or only the ListFragment. If both are visible, you have to notify the details fragment that new item is selected so it can show its data. Otherwise you have to create new details fragment (you reuse it of course), pass it some information about the selected item (so it can show the item's data) and replace the ListFragment with the new one.
That a basic overview, but it should be enough to give you some idea about this flow. If you need any more details - just let me know. :)
Master/detail flow and blank activity is not same as you want to change by only changing app theme or app base theme. It will be better, if you first design master/detail flow template using UI fragments, then according integrate you blank activity with the master template making necessary changes. And for master/detail flow tutorial just google it, you will find lots of example there.
Here are some links from developer.android.com fragment-ui and adaptui
These are some guidelines about fragments but they are told using a master/Detail app.
Also dont forget to checkout the news reader app provided as sample in the second link.
If you have a recent version of the Android SDK, you should be able to create a new Android application and during that process you can elect to have the wizard create a Master/Detail Flow app for you. It will create a basic working app so that you can look through the code and understand the necessary parts.
Then, depending on how simple your app is, you may want to move all your present code to the new application or vise versa.
Macro changes that will happen:
Change all your current Activities to extend Fragment instead.
You will have to create a FragmentActivity to call your Fragments. This will basically be the boilerplate code, with just the names of your Fragments added to it.
Don't forget to double check your Manifest!
In your converted Fragments that previously extended Activity:
Everywhere you needed a Context, switch that with getActivty() (or create a global variable so that it is only called once)
Change onCreate() to
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mView = inflater.inflate(R.layout.fragment_signals, container, false);
setHasOptionsMenu(true); // Add if you want to display a Menu
// Your initiation code here
return mView;
}
If you have a menu, change it to
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.activity_main, menu);
super.onCreateOptionsMenu(menu, inflater);
}
And that's it for basic applications. When you first change Activities to Fragments, there will be many errors. But, they are all easy to fix.

How to Determine XML layout for Fragments in Tabs?

Okay, So I just started Android development (I am average at VB.Net, so I understand basic code even if its not in VB). I've made a couple play around apps which used Text-To-Speech, Async Tasks and Reading/Writing files. However, I now wish to make a tabbed Android app.
I started the project in Eclipse Juno and filled in all the details. I then selected (For navigation) the Tabs/Swipe layout. I now have the default code for that layout type (Link to Tabs on developer.android.com - http://developer.android.com/design/building-blocks/tabs.html).
I understand mostly what the default code is doing. The only problem I am having, is determining the individual layout of my Tabs. I wish to have 2 Tabs, 1 in which the user selects an option, and the other, in which an image is shown depending on the selection in Tab 1.
So the question is: How do I create a .xml file in Layout to determine what is shown on the Fragment?
If you want to do this in XML the answer is simple, it can't be done just with XML, you must create a class that's implementing a ActionBar.TabListener.
Than you can override the onTabSelected method in which you can exchange the content.
A proper solution would be:
Use a LinearLayout as root container, and implement two Fragments for each of your Tabs (there you can design an individual XML-layout). Now you can add one fragment initially to the root-container and implement the exchange of the layouts inside the onTabSelected method and you are done.

View different images depending on what item in my list view I click

I'm fairly new to Android programming and I've got this project I need to finish and I'm currently stuck.
I've got a standard listview in a Menu class with an array containing around 20 different elements. So what I want to do is load images in an imageview depending on which item in the listview I click, and since I'm a beginner the only idea I had was to make a new activity for each imageview which seems like a pretty bad way to do it since I'd need about 20-30 new activities..
To sum things up what I want is:
Code for making ONE activity that will display a different image depending on which item in the listview I click, probably pretty basic coding I want as simple solution as possible.
If possible I'm also looking for a solution that includes an SQLite database that stores the URL of an image and then display it in a single activity, also depending on which item I press in my current listview.
(I hope you understand my needs, and if you need I can also post my current code for the Menu class if it helps you help me) Or you can just show me a different way to make this work, I appreciate every answer! Thanks in advance!
NOTE
And please keep in mind, I'm a noob at Java and Android so keep it rather simple or at least explain what you do.
When you click on a list item, display the image in another view in the same layout, unless you want the image to take up the entire screen real estate. If you want it in the entire screen, go to a new Activity by sending the activity an Intent.
Activities are the "controller" of your application. They interact with the visible UI and the input from the user. You don't need a separate activity for each image, just an activity that's associated with a "place" in the UI (an ImageView) where you'll display the image.
I'd start by adding the images as resources under res/drawable before going on to databases.
You are going to have to do most of this yourself. There really isn't any substitute for taking the time to learn Java and Android. There are several tutorials and Android University classes under the Resources tab in the Developers Guide; I suggest you do all of them.

Categories