Create an horizontal menu - android

I'm new to Android development and I have to build an Android version of a iOs app. I have to build an horizontal menu in the bottom of the screen. Something like MOVIES|TV SHOWS|PERSONAL VIDEOS in this image
How do you suggest me to proceed? If I did an activity layout with a tabbed o linear layout at the bottom and fragments for the above contents?

#Ivan Lasorsa :
You can use ViewPager Fragment as main layout and for individual pager views we use Fragments. The tabs are part of Action Bar.
Swipe-view should consume the entire layout, then your layout looks like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
So please take a look Android Tab Layout with Swipeable Views Here . I hope it will helps you .

It's the tabbed activity, here is the doc ;)

I don't recommend bottom tab bar
because it causes the wrong touch
Pure-Android : http://developer.android.com/design/patterns/pure-android.html
but if you have to implement, you can read to
https://stackoverflow.com/a/7431480/2530660

Related

Android: how to make frame layout covering other UI components from the bottom?

I would like to display on the bottom of the view frame layout which has some layouts inside of the FrameLayout hidden and are displayed after some button click. I would like to display the FrameLayout to start from bottom of the screen above all other views.
How can i do it in the right way please?
Many thanks for any advice.
I have implemented something similar to what you would like to achieve...first of all you should place your entire Activity of Fragment layout inside a CoordinatorLayout. Then you should place the FrameLayout which you want to show above all other views as the last View inside the CoordinatorLayout. You could give the FrameLayout a fixed height(200px) and the same negative value as margin bottom(-200px) so it can not be visible in the first place. And after some button click you can animate your desired view (in this case FrameLayout) to overlap all other views starting from the bottom of the screen.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
//Your views here
<FrameLayout //Your FrameLayout
android:layout_width="match_parent"
android:layout_height="200px" android:layout_marginBottom="-200px">
//Place whatever views you prefer here
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
Since Android Support Library 23.2 you can use Materials Bottom Sheets like the Google Map one:
Include the support design library (use the most recent version):
compile 'com.android.support:design:24.1.1'
You are supposed to use a component which is aware of nested scrolling like NestedScrollView (which extends FrameLayout by the way) and RecyclerView inside a CoordinatorLayout and add this behavior to it:
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
And to make it visible on the bottom just a little:
app:behavior_peekHeight="64dp"

I want to devleope dynamic android screen like this

I want to develope screen like the below..which contains two tabs with right alignment!
actually it's the dynamic screen and top part should be fixed with two tabs when ever they click the tabs it's different fragment. please suggest me the best way.
You can use ViewPager for this.
<android.support.v4.view.ViewPager
android:id="#+id/vpPager"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v4.view.ViewPager>
Here is a link for your reference.
Design two different layout files and switch them on Tabchange.
You can either use RadioGroup to act like tabs with fragments
like this https://stackoverflow.com/a/17541555/3020568
OR you can use PagerSlidingTabStrip library and customize it like the way you want
https://github.com/astuetz/PagerSlidingTabStrip

add scroll tabs between some layouts

I want to add scrollable tab in an xml file. Normally I can add it like
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.scrollabletab.MainActivity" />
and it looks like:
but now I want to add this scroll tab at center of view. Center means above this scroll tab I have app logo, some layout which contains different textviews. and also I want to add some layout below this scroll tabs which again contains different textview and layout.
How to do this?
You can try this one widget: http://viewpagerindicator.com/
But common answer is: use Actionbar with Tabs:
http://developer.android.com/guide/topics/ui/actionbar.html#Tabs
Why don't you use a ScrollView within the layout that you use for your pager?

How add custom view top of the android action bar

How to add a custom view top the android navigation bar like above image. when user click on the action bar need to push the main content down and add the custom layout top of the action bar.please how to accomplish this any one suggest a solution
Thanks
Rahul
An easy solution would be to use those views in the actual ActionBar like this: http://developer.android.com/guide/topics/ui/actionbar.html#ActionView. And then take all your layouts and put them inside a RelativeLayout and set their android:layout_below="" to a layout that corresponds to the ActionBar you want to use. So in a step by step way:
Create an action_bar.xml that has the items you want your actionbar to have (ImageViews or Buttons, w/e)
Include this layout in all the Layouts you will use (or in your main layout if you're using Fragments to display content).Like this:
<include layout="#layout/action_bar"
android:id="#+id/action_bar"
android: ... />
Make your Layout position itself below this layout (Using a FrameLayout for example)
<FrameLayout
android:id="#+id/content_frame"
android:layout_below="#+id/action_bar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
Include the ActionViews (Spinner and tabs) in the ActionBar like it's taught in the link up there.

vertical DrawerLayout or SlidingPaneLayout

The latest Android Support Library introduced the DrawerLayout to implement the common UX pattern where you slide right or left to show a navigation menu.
What I'd love to have is a vertical DrawerLayout with the same API, that can be pulled down/up from the top/bottom of my layout.
Since 4.2 the old SlidingDrawer has been deprecated and I haven't heard about some new Widget that implements the same functionality.
Can the DrawerLayout be extended somehow to implement the vertical swipe UX pattern?
Does google provide some different widget to implement it?
Google Music for instance has something very similar to what I'm looking to implement to pull up the player.
We have recently implemented this in the Umano App and open sourced: https://github.com/umano/AndroidSlidingUpPanel
Enjoy.
The Android support library now has the bottom sheets behavior to do that.
Check out this link for more info https://material.google.com/components/bottom-sheets.html
Nowadays, it makes more sense to use the BottomSheetBehavior that you can find more information on how setting it up on https://code.tutsplus.com/articles/how-to-use-bottom-sheets-with-the-design-support-library--cms-26031
Basically, you need to set your main content, and your sliding content. The BottomSheetBehavior would only work for panels that you slide from the bottom to the top.
It has a quite simple set up and the BottomSheetBehavior could even work out of the box. Only by writing a android.support.design.widget.CoordinatorLayout layout, with another View inside (with even wrap_content as a value in the layout_height parameter), for instance a LinearLayout like this one:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:behavior_hideable="true"
app:behavior_peekHeight="56dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
<!-- Your content goes here -->
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
In my case, I inflate this layout in a Fragment and add it to the Activity where you want to enable the SlidingSheetBehavior.

Categories

Resources