Android: Able to Click through the nav drawer?? AppCompat v7:r21 - android

When I open my navigation drawer in an android app I created, I'm still able to click on list items in my main layout (The content layout). I mean, I am actually able to click on a ListView item through my navigation drawer. I don't have any clickable items in the navigation drawer yet, but I've put it in a proper FrameLayout with a white background. The content of the drawer, I am designing in a fragment. Here is my code:
activity_home.xml (MainActivity)
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
tools:context=".HomeActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="#+id/toolbar_home"
layout="#layout/my_awesome_toolbar" />
<FrameLayout
android:id="#+id/main_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" />
<ImageButton
android:id="#+id/fab_addContact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_marginBottom="#dimen/view_margin_large"
android:layout_marginEnd="#dimen/view_margin_large"
android:layout_marginRight="#dimen/view_margin_large"
android:background="#drawable/fab_button"
android:contentDescription="#string/fab_contDesc"
android:padding="#dimen/view_margin_large"
android:src="#drawable/ic_add_white_24dp" />
</FrameLayout>
</LinearLayout>
<FrameLayout
android:id="#+id/drawer_frame"
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#android:color/white"
android:clickable="true" />
</android.support.v4.widget.DrawerLayout>
fragment_drawer.xml (DrawerFragment to go into the #+id/drawer_frame )
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="144dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="#drawable/material_design_wallpaper" />
<ImageView
android:id="#+id/iv_userThumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_margin="16dp"
android:background="#drawable/display_pic_thumbnail"
android:contentDescription="#string/contact_thumbnail" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/view_margin_xx_large"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#drawable/shadow" />
<TextView
android:id="#+id/tv_userName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/tv_userEmail"
android:layout_alignLeft="#+id/tv_userEmail"
android:layout_alignStart="#+id/tv_userEmail"
android:layout_marginBottom="#dimen/view_margin_small"
android:text="Siddhant Chavlekar"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_userEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="#dimen/view_margin_large"
android:layout_marginLeft="#dimen/view_margin_large"
android:layout_marginStart="#dimen/view_margin_large"
android:text="siddhant.chavlekar87#gmail.com"
android:textColor="#android:color/white" />
</RelativeLayout>
</LinearLayout>
Why is this happening? I'm using the AppCompat v7:r21 library to provide backwards compatibility for my Lollipop (Material Design) Apps.

So, I put the above mentioned line which is android:clickable="true" in my drawer_frame FrameLayout and so far I haven't come across any difficulties. Although, if I put it in my other layout, the bug still arises...
So I guess the solution is to put android:clickable="true" in the layout which represents the drawer. (The layout with android:layout_gravity="start")

Related

Communicate between fragments and layouts

I don't really know how to ask this question but I will start off with the idea here.
So I have a MainFragment that contains a SlidingUpPanelLayout that includes a viewpager and a layout that hold the controls for the application.
And what I want to do is when I change between fragments in the tablayout I want to change the layout of that holds the controls, I also want to trigger functions from the fragment with the controls in on my different fragments in the viewpager.
But since they are in different fragments I don't know how to get the control layouts and buttons to change and get a hold of them.
So here is first an image of the layout:
https://imgur.com/a/SgdI21L
And here is how my following XML looks like:
XML for the Control Content:
<LinearLayout android:id="#+id/control"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000"
android:clickable="false"
android:gravity="center|top"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.TabLayout
android:id="#+id/tabLayout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#color/controlBackground"
app:tabGravity="fill"
app:tabIndicatorColor="#color/colorText"
app:tabMode="scrollable"
app:tabSelectedTextColor="#color/colorAccent"
app:tabTextColor="#color/colorText">
</android.support.design.widget.TabLayout>
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.FloatingActionButton
android:id="#+id/takePicture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|center_vertical"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:backgroundTint="#color/colorText"
android:clickable="true" />
<ImageButton
android:id="#+id/flipCamera"
style="#android:style/Widget.Material.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|left"
android:padding="20dp"
android:clickable="true"
android:tint="#color/colorText"
android:backgroundTint="#color/colorText"
android:src="#drawable/ic_outline_camera_front_24px" />
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/openGallery"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center|right"
android:padding="20dp"
android:src="#drawable/fox"
android:clickable="true"
app:civ_border_color="#FF000000"
app:civ_border_width="2dp" />
</android.support.design.widget.CoordinatorLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center|top"
android:padding="10dp"
android:text="Pete is king!"
android:layout_gravity="center"
android:textColor="#color/colorText"
android:textSize="16sp" />
<ImageButton
android:id="#+id/info"
style="#android:style/Widget.Material.Button.Borderless"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|end"
android:layout_weight="1"
android:padding="20dp"
android:clickable="true"
android:backgroundTint="#color/colorAccent"
android:tint="#color/colorAccent"
android:src="#drawable/ic_shutterowl_24dp" />
</LinearLayout>
</LinearLayout>
And here is my viewpager:
<android.support.v4.view.ViewPager
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<owlapps.shutterowl.AutoFitTextureView
android:id="#+id/texture"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_toEndOf="#+id/control"
xmlns:android="http://schemas.android.com/apk/res/android" />
</android.support.v4.view.ViewPager>
They are all showed together in a SlideUpPanelLayout like so:
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
xmlns:sothree="http://schemas.android.com/apk/res-auto"
sothree:layout_constraintHeight_max="80dp"
sothree:umanoPanelHeight="120dp"
sothree:umanoShadowHeight="0dp"
sothree:umanoOverlay="true">
<include layout="#layout/camera_content"/>
<include layout="#layout/control_content"/>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
I had an idea to solve this with a interface that could trigger functions from the MainFragment that loads the camera and content layouts, here is what i tried:
In a click event from the mainfragment: Tab1Fragment.take.visible(true);
My interface looks like this:
public interface CameraControlListener {
void visible(boolean status);
}
And is implemented in the Tab1Fragment that holds the camera view:
#Override
public void visible(boolean status) {
if(status){
takePicture();
}
}
So how can I get all these to speak with eachother?
As i move between fragments i want the controls to change that are inside another fragment and also trigger functions from the active tabfragment in the viewpager.

Android fragment only partially re-rendering

For some reason, the UI of my fragments is not correctly re-rendering anymore with the new SDK. This is only the case on Android devices with Android 8.0 or higher.
When changes are made in the UI it seems that only 1 fourth of the screen is actually rerendered. So old items are still visible on the screen, and new items are only rendered in the upper left 1/4th of the screen.
When I start dragging (even just a little bit) the view readjusts and renders completely.
I have added some pictures below to demonstrate what is happening. To make it more clear, I have colored the background of the fragments red and blue, so you can see which part has rerendered. As you can see in picture 2, only a part of the fragment has rendered. In picture 3 after dragging a bit (there are multiple tabs) the fragment is completely rendered.
1 Before UI update
2 After UI update
3 After UI update and dragging
The layout for my viewpager / tablayout activity is as follows:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMaxWidth="0dp"
app:tabGravity="fill"
app:tabMode="fixed"
android:fillViewport="false" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
The layout in my fragment is as follows. There are two parts. Only one is visible at a time and the other has visibility GONE. The RelativeLayout with id "step1" starts as VISIBLE and the one with "step2" starts as GONE. When pressing the button "step1" will be set to GONE and "step2" to VISIBLE.
<RelativeLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".depot.fragment.StockFragment">
<RelativeLayout
android:id="#+id/step1"
android:background="#color/holo_blue_dark"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kies het pand" />
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:id="#+id/radio_group">
</RadioGroup>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:id="#+id/footer">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"/>
<Button
style="#style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:id="#+id/button_next"
android:text="Volgende"/>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/step2"
android:background="#color/holo_red_dark"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/header_step2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:id="#+id/depot_choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/Material.header"
android:text="Kies het pand" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="Klik op de knop rechtersonderin het scherm om scannen te starten." />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/tableContainer"
android:layout_below="#+id/header_step2"
android:layout_above="#+id/footer_step2">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</android.support.v7.widget.RecyclerView>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:elevation="6dp"
app:backgroundTint="#color/accent"
android:src="#drawable/ic_border_color_black_24dp"
android:id="#+id/floating_qrcode_manual"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#+id/floating_qrcode_scan"
android:layout_toStartOf="#+id/floating_qrcode_scan"
android:layout_marginBottom="10dp"
android:layout_marginRight="20dp"
android:layout_marginEnd="20dp"/>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:elevation="6dp"
app:backgroundTint="#color/accent"
android:src="#drawable/qrcode_scan"
android:id="#+id/floating_qrcode_scan"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:layout_alignParentEnd="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:id="#+id/footer_step2">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/divider_light"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"/>
<Button
style="#style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="#+id/button_prev"
android:text="Ander pand kiezen"/>
</RelativeLayout>
</RelativeLayout>
Could anyone help me find the problem with this code?
I finally managed to track down the problem.
It had nothing to do with the ViewPager. Only there were settings in the AndroidManifest that messed up the re-rendering of fragments after android 8.0.
The settings that caused the problems were the following:
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
Removing these solved the problems.

RecycleView Not Scrolling by adding RelatvieLayout below It

I have viewpager at the top to slide and view images . and after a list to see remaining images or whatever i want to display in list and after that i have a RelativeLayout below this list which i will populate with the Code
Now Issue is :-
I am facing a problem with RecycleView . It was working fine until i add a RelativeLayout to parentofbottom and setting RecycleView property to above this RelativeLayout . Now Issue is RecycleView is not scrolling at all . whats wrong with the code. What needs to be change .Or Suggest me anyother way to achieve this design
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:focusableInTouchMode="true"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/relativeHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#color/headecolor" >
<Button
android:id="#+id/btnOpenDrawer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#drawable/menu_icon" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/alert_icon" />
<TextView
android:id="#+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textStyle="bold"
android:text="A La Une"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/blackColor" />
</RelativeLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/scroler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/relativeHeader"
android:fillViewport="true"
android:background="#android:color/white" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
android:background="#android:color/white" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="wrap_content"
android:descendantFocusability="blocksDescendants"
android:layout_height="wrap_content" >
<RelativeLayout
android:id="#+id/rlPager"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<egdigital.alpes1.view.WrapContentViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="220dp"
android:adjustViewBounds="true"
android:background="#drawable/news_img_transparent"
/>
<ImageView
android:id="#+id/imageView_dot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/view_pager"
android:layout_alignParentLeft="true"
android:src="#drawable/scroll_dot1" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlRecycle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeLayout1"
android:layout_above="#+id/rlMiniPlayer"
>
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="80dp">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlMiniPlayer"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_alignParentBottom="true"
>
</RelativeLayout>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</RelativeLayout>
<fragment
android:id="#+id/navigation_drawer"
android:name=".NavigationDrawerFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_marginLeft="25dp"
tools:layout="#layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
1) Change
android:layout_below="#+id/relativeLayout1"
to android:layout_below="#id/relativeLayout1" and change anywhere else you have layout_below or layout_above
+ is used when creating a new id. When giving an already created id we use it without +
2) You don't really need RelativeLayout with id rlRecycle. You can directly move layout_below and layout_above attributes to RecyclerView because it's already under top level RelativeLayout
I Found The Solution . i know there are lots of extra RelativeLayouts . Know I removed it . and putted rlMiniPlayer below the nested scrollview
Because I am using nestedscrolling=true . in the code . This is creating the problem
Like This :-
</android.support.v4.widget.NestedScrollView>
<RelativeLayout
android:id="#+id/rlMiniPlayer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
>
</RelativeLayout>

CardView and other elements are not being displayed in my xml file

I am using an AppCompatActivity and at the moment, I am trying to add a navigational drawer to the toolbar.
Problem is, now the cardview is not being displayed and the navigational drawer is also not working.
This is my code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="150dp">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/cards"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="200dp"
card_view:cardCornerRadius="4dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="10dp"
android:layout_alignParentBottom="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Username"
android:id="#+id/usersName"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Others"
android:id="#+id/others"
android:layout_centerVertical="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"></android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
Would really mean a lot and make my day if someone could fix my error please. I don't know where I have gone wrong, and I just want to have the navigation drawer button in the toolbar and the cardview on the screen
Youre trying to squeeze a 200dp cardview inside a 150dp container. Use match_parent for drawerlayout.
Then, straight from the developer guides:
The main content view must be the first child in the DrawerLayout because the XML order implies z-ordering and the drawer must be on top of the content.
The main content view is set to match the parent view's width and height, because it represents the entire UI when the navigation drawer is hidden.
For more information follow the developer resources
Try this solution, this has android:layout_gravity="start" in NavigationView and CardView android:layout_height="match_parent" and some other minor changes.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="150dp">
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/cards"
android:layout_width="match_parent"
android:layout_height="match_parent"
card_view:cardCornerRadius="4dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:padding="15dp">
<TextView
android:id="#+id/usersName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="Username"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/others"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="Others"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:fitsSystemWindows="true">
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>

SlidingDrawer over GoogleMap

First of all, I know the SlidingDrawer is deprecated, but I haven't found any alternative to it so I'm using it anyways :3 (If someone knows an alternative to it, please share it!)
So I have a GoogleMap in my activity (actually a fragment but it doesn't matter), and a nice SlidingDrawer in the same screen. It works fine, but when I open or close the slidingdrawer over the map, it starts behaving weird. It looks like the map want's to stay in front of the slidingdrawer. When the drawer is fully opened, then it comes back to the front and everything is ok.
Is there a workaround for this? I am getting crazy!
here is my layout:
<RelativeLayout 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/window"
>
<fragment
android:id="#+id/hackedmap"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
<SlidingDrawer
android:id="#+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:content="#+id/drawercontent"
android:handle="#+id/drawerhandle"
android:orientation="horizontal"
>
<LinearLayout
android:id="#id/drawerhandle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
android:gravity="center" >
<ImageView
android:id="#+id/slidingHandle"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitEnd"
android:src="#drawable/sliding_handle" />
</LinearLayout>
<LinearLayout
android:id="#+id/drawercontent"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#DD000000"
android:gravity="center_horizontal|top"
android:orientation="vertical" >
<TextView
android:id="#+id/selectednet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="4dp"
android:text="Select a network:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#02bceb" />
<ListView
android:id="#+id/passivelist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice" >
</ListView>
</LinearLayout>
</SlidingDrawer>
</RelativeLayout>
Put the map inside of a relative layout. In front of the map a view with the same measure.
Example:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<include
android:layout_width="wrap_content"
android:layout_height="250dp"
android:layout_weight="1"
layout="#layout/general_map_fragment" />
<View
android:id="#+id/imageView123"
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="#color/transparent" />
</RelativeLayout>

Categories

Resources