I want to show and hide the action bar /toolbar as the Google Play store app. I am using sliding tabs on top and view pager to show the content of each tab. Here is the screenshot of Google play store app for the reference:
My layout XML :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<LinearLayout style="#style/HeaderBar"
android:id="#+id/headerbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="#layout/toolbar_no_bg"
android:id="#+id/toolbar_actionbar"/>
<com.fauzie.sample.tabsspinner.widget.SlidingTabLayout
android:background="#color/tab_background"
android:id="#+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<android.support.v4.view.ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/headerbar">
</android.support.v4.view.ViewPager>
</RelativeLayout>
Thanks in advance.
Have a look at this:
https://github.com/flavienlaurent/NotBoringActionBar
There's a trick involved here. You'll need to:
Wrap your layout in a list view
Add a fake header with the same height as your action bar large header
set your action bar overlay to true
Translate the real header when the list moves (i.e. when the fake header is scrolled).
It's a little bit complicated at first but once you understand it, you see how smart and obvious it all is. The link will give you all you need I hope.
I myself used that link to implement it in my own app and it works great.
Checkout this library: https://github.com/ksoichiro/Android-ObservableScrollView
this will definitely help you
Check this example to implement this with the new official Android Design Support Library:
https://github.com/chrisbanes/cheesesquare
Related
I want create a menu in my application which has no action bar... I want to make it just like you can see in chrome browser... Please help me with this and sorry for I don't have any code I made for this purpose ....Thanks in advance
I don't really get what you are asking, so I will try to list all posible meanings:
Use Toolbar(ActionBar)'s menu but layout doesn't have Toolbar:
Just add a toolbar to your layout:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</com.google.android.material.appbar.AppBarLayout>
...
</LinealLayout>
Custom Toolbar
I have never tried to inflate Menu into a non-Toolbar and I think it is not possible. Please correct me if you have tried! So I think you must implement every view/button, etc... one by one.
No toolbar, just menu (Popup ?)
https://www.geeksforgeeks.org/popup-menu-in-android-with-example/
I am trying to achieve a similar look like the Google Play Store App
For now I got this
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/image"
android:layout_width="match_parent"
android:layout_height="200dp" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingTop="200dp" />
</FrameLayout>
Looks great but since the Recyclerview is overlapping the ImageView, it's not clickable anymore. I am looking for a solution.
You can make use of scrolling activity template in the android studio it has similar behaviour to what you want to do.
and put ImageView in AppBarLayout
and handle the click events like any other view.
this won't give you the exact behaviour of google play app but if it's the eases way to do it.
if you want the exact behaviour I know an open source library that do that let me know if you want it and I will search for it.
I'm trying to replicate this animation in Google's Play Newsstand app:
http://i.imgur.com/UuX1PRO.webm
I have a layout that looks something like this:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="8dp"
android:orientation="vertical">
<LinearLayout
android:id="#+id/post"
android:layout_width="match_parent"
android:layout_height="250dp"
android:orientation="vertical">
... more layouts ...
</LinearLayout>
</LinearLayout>
How can expand the LinearLayout (with ID post) to expand to the screen? Note that the height of all posts is 250dp. When the post has expanded to the screen, I want to load the replies made to the post below it (comments section).
How can I create this animation/expand effect?
You need to use material design activity transition
See here
getWindow().setExitTransition(new Explode());
Check this
You need to use an Activity transition. The article view is in fact a different Activity. See the documentation: http://developer.android.com/training/material/animations.html#Transitions
You can simply add the following line of code to your Activity.onCreate();
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
This is not exact solution but I think this page on developer site is exactly what you are looking for.
I want to create news like activity that has title and date and some share and favorite buttons in the beginning at the top, the article text (and maybe some images and headers titles) is in html that I get from server, and at the end a list of related news!
I have to use WebView for the article html, but since I need the header and the main webview to scroll together, I may have to use them in the in wraping ScrollView, which, apparently is not the best option!
I have red these:
webview in scrollview and
Disable scrolling in webview
but I want to know what is the best way to implement this as of 2015! that can work with android 4.01+
Well, as it turns out, best way to do yet is to just put them in a scrollView !
It worked on my Samsung android 4.4, but I don't know about the rest !
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/news_activity_title_lay"
android:layout_width="match_parent"
android:layout_height="wrap_content">
//Some Widgets Here for header
</RelativeLayout>
<WebView
android:layout_below="#+id/news_activity_title_lay"
android:id="#+id/news_activity_web_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white">
</WebView>
<LinearLayout
android:id="#+id/news_activity_related_base_lay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="#+id/news_activity_web_view">
//Some Widgets Here foe footer
</LinearLayout>
</RelativeLayout>
funny thing, though is Android Studio is saying I should not do this ! :/
I'd like to create an extra-information view similar to that of the Google Drive app (below) on a tablet. When the info button is clicked, this view slides in from the rightcontaining a layout. Another example would be the Google+ app with its notifications slide-out panel:. The SlidingLayer by 6Wunderkinder almost works, but doesn't fade a semi-black background over the views behind the "drawer" and I haven't found another library that does this.
If anybody has any suggestions/solutions please let me know!
Also, I've already looked at this question and none of the answers suggested there are correct either.
For posterity, here's the answer to this question. As Steve Benett's suggestion led me to discover, the correct way to do this is to use two DrawerLayouts, nested within each other like so:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_navigation_bar"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_sidebar"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="#+id/fragment_main_content"
android:name="MainContentFragment"
android:layout_height="match_parent"
android:layout_width="match_parent" />
<fragment
android:id="#+id/fragment_sidebar"
android:name="SidebarFragment"
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="end" />
</android.support.v4.widget.DrawerLayout>
<fragment
android:id="#+id/fragment_navigation_bar"
android:name="NavigationFragment"
android:layout_height="match_parent"
android:layout_width="300dp"
android:layout_gravity="start" />
</android.support.v4.widget.DrawerLayout>
The innermost DrawerLayout contains the main content of the Activity, whether it be a fragment or some other layout components. fragment_sidebar is the fragment that will be swiped out from the right. Then, on the top-level DrawerLayout you have the fragment_nagivation_bar which houses the left Drawer's ListView or whatever.
Then, in the Activity Java code you have:
mDrawerLayoutLeft= (DrawerLayout) findViewById(R.id.drawer_navigation_bar);
mDrawerLayoutRight = (DrawerLayout) findViewById(R.id.drawer_sidebar);
mDrawerLayoutLeft.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
mDrawerLayoutRight.setDrawerShadow(R.drawable.sidebar_shadow, GravityCompat.END);
An optional addition (but recommended, for consistency of UX) is to hide the other Drawer when one is opened, so your screen doesn't consist solely of Drawers.
I hope this has helped somebody!
This is the DrawerLayout. Have a look at the design guide, which illustrates the behavior well.
If you want to use / customize the "semi-black background" use DrawerLayout.setDrawerShadow() with a drawable. Google hands out a set of drawables here. Download the ActionBar Icon Pack and look for the drawable_shadow.9.png.
If you want that the menu appears from the right, set android:layout_gravity="end" as a property in the second child of the layout.