Android semi transparent sliding drawer - android

I want to make an iOS 7 like drawer that I can slide from the bottom that doesn't cover the full screen and is semi transparent/blurred on Android.
I had a look at SlidingDrawer on android to try and get a start but it looks like its being depreciated. How can I create a similar future proof effect on android?

Just change the background color of the List view that gets populated in navigation drawer fragment.
use of background color "#22FFFFFF" makes navigation drawer semitransparent
Use an hexadecimal color code, which consists of two digits for alpha and six for the color itself, like this:
use android:background ="#88676767" change the first 88 to your selection of opacity
android:background="#c0000000" -for more darkness
Please rate it if it turns helpful.
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="0dp"
android:background="#22FFFFFF"
tools:context="com.Navigation Drawer Fragment" />

Related

how to make hamburger menu fully visible

by default half of hamburger is shown, as seen at the top left corner of the screenshot. I want to display full hamburger. code is taken from https://developer.android.com/training/implementing-navigation/nav-drawer.html. how can I do this?
Seems you are using very old technique to create Navigation Drawer. Its around 4 years old code and seems perfect regarding old version.
FYI, previously this kind of UI was done using DrawerLayout with ListView. But now android itself officially introduced sliding panel menu by introducing a newer concept called Navigation Drawer in which we combine DrawerLayout and NavigationView to achieve the desired output.
How to make hamburger menu fully visible?
SOLUTION:
Use AppCompatActivity instead of Activity and use AppCompat theme to achieve your desired output.
Use NavigationView instead of ListView.
Here is an example of NavigationView:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<!-- Your contents -->
<android.support.design.widget.NavigationView
android:id="#+id/navigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="#menu/my_navigation_items" />
</android.support.v4.widget.DrawerLayout>
Here is a very good tutorial: Android Sliding Menu using Navigation Drawer
Hope this will help~

Navigation Drawer Background Color [duplicate]

I am creating an App with a Navigation Draw Activity. In android studio, after I start a new android activity project, I select Navigation draw activity. My question is, how to a change the background color of the navigation draw activity? Right now, the top part is green but the white part where the text and icons are is white and I want to change this white part to dark grey with white text.
Thanks.
Rob
Go to res -> layout -> activity_main.xml and add the following:
<android.support.design.widget.NavigationView
app:itemTextColor="#A9A9A9" // text color
android:background="#FF0000" /> // background color
The top part it is defined in res -> layout -> nav_header_main.xml and the same color definitions apply to it too. Look for :
<LinearLayout android:background="#drawable/side_nav_bar" />
and change it to any color you want.
I just made some changes.
To define the color there are two ways to use the colors file in the values ​​directory or define in hexadecimal as for example android: background = "# 84FFFF".
<android.support.design.widget.NavigationView
android:id="#+id/ejemplo_nav_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/ejemplo_nav_header"
app:menu="#menu/ejemplo_drawer_view"
android:background="#color/color_define"/>

Android SlidingPaneLayout Fade

I am trying a prototype app with SlidingPaneLayout. My SlidingPaneLayout is gray and body view is pure white.
but when i slide in, the small visible area of body page goes slightly dark or overlaying with dark screening. all i want is pure original white color of that body view.
I tried couple of Methods to switch off these but seems impossible. such as
SlidingPaneLayout sp = (SlidingPaneLayout) findViewById(R.id.mainSlider);
sp.setHorizontalFadingEdgeEnabled(false);
or following property in XML
<android.support.v4.widget.SlidingPaneLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/mainSlider"
android:requiresFadingEdge="none" <!-- try one -->
android:fadingEdgeLength="0dp" <!-- try two -->
android:fadingEdge="none" <!-- try three -->
tools:context=".MainActivity">
Any one of you, have you ever done this successfully?
You can set the fade color to transparent:
SlidingPaneLayout sp = (SlidingPaneLayout) findViewById(R.id.mainSlider);
sp.setSliderFadeColor(getResources().getColor(android.R.color.transparent));

Android NavigationDrawer transparency

I’ve implemented NavigationDrawer with android-support-v4 as per this tutorial
My result is on this screenshot.
The question is how to remove or configure these transparency on Drawer which looks awful with background text.
UPDATE:
here is my layout configuration, with background been set to dark
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ListView
android:id="#+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="0dp"
android:background="#111111"/>
</android.support.v4.widget.DrawerLayout>
You need to add alpha to your ListView.
Use your XML and extend the ListView definition with alpha-attribute.
<ListView
android:id="#+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="0dp"
android:background="#111111"
android:alpha="255"
/>
Use this in you code.
Get the background of the drawer view and set alpha for it.
Drawable background = drawerView_.getBackground();
background.setAlpha(255);
Thanks everyone who tried to answer my question.
I'm sorry the trouble was in Fragment initialization in code.
So I've tried to add fragment as new instance, but it should be just a replacement of already defined fragment in layout as follows:
android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
FeedFragment fragment = new FeedFragment();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
now everything works fine.
To make navigation drawer transparent, you must first define the color for your drawer in res/values/colors.xml file.
Eg:<color name="navigationDrawerNew">#7ba9530c</color>
Now, on the left side of this line, the color that you have chosen will be displayed in a small square.
See image for example
Click on it. It will bring up a color chooser. In the color chooser, at the bottom, there is a slider which allow you to adjust transparency. Adjust it to get the required transparency.
Now, set this color as background color for the list view for navigation drawer in xml file. The list view looks almost like this:-
<ListView
android:id="#+id/navList"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_gravity="left|start"
android:background="#color/navigationDrawerNew" />
Set the Background of the Drawer (Which in the linked demo is a ListView) to a solid color/drawable
It doesn't default to be transparent like this. You must have it set in your activities layout file. Change the android:background in the android.support.v4.widget.DrawerLayout tag to be a solid colour
What's the layout that your Adapter inflates in the
getView(LayoutInflater inflater, ..., ...) ?
The ListView inflates some layout and this one seems to be transparent, not the drawer.
The background color of your Drawer becomes the color of ListView's items.
You can notice that the second part of your drawer is a little bit darker then the items.
You only need to setBackgroundColor for DrawerListView in the code like this:
mDrawerListView.setBackgroundColor(Color.LTGRAY);
This is work for me. No need to add Alpha value.
You add background color of ListView in java file then it works correctly,
listview.setBackgroundColor(Color.WHITE);

How to create bottom menu like gmail android

I am not quite sure what kind of layout Gmail is using in Android.
I suppose they use a floating ViewGroup.
But for the menu on the top and bottom I really need somebody point me how to make that.
I suggest you to use the Sherlock ActionBar:
http://actionbarsherlock.com/
This allows you to easily develop an application with an action bar for every version of Android from 2.x and up.
In the sample app you can find the code to achieve what you are looking for under "Split Action Items". The idea is that you add actions from the menu as usual, but writting the following line in your manifest activity:
android:uiOptions="splitActionBarWhenNarrow"
You can create a menu which will sit on the bottom of a listview using the <RelativeLayout> tag like so
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ListView
android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="#android:id/list"
android:listSelector="#android:color/transparent"
android:layout_above="#+id/footer" />
<include android:id="#+id/footer" android:layout_height="wrap_content"
layout="#layout/mymenu" android:layout_width="fill_parent"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true" >
</include>
</RelativeLayout>
mymenu will contain a linearlayout with something like a tablelayout with a few rows (which can be textviews, imageviews, etc.) The table will sit at the bottom of your screen and the listview will be in a frame which starts at the top of the screen and ends at the top of the menu (no overlap)
You could also do the same for the top of the screen by simply having the listview say layout_below="#+id/header" instead of layout_above"#+id/footer" (or do both!)
This is covered on android. You have to implement a "split action bar". Note that it works in potrait view and disappears when you switch to landscape.
Android Action Bar
It looks like a custom ActionBar implementation. If you put icons in a normal ActionBar and there is not enough space to display them, android creates a bottom bar on its own and display the icons there.
I had a similar application and I chose to put my own custom bar there instead of implementing ActionBar

Categories

Resources