SlidingDrawer over GoogleMap - android

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>

Related

Softkeyboard pushes whole layout to the top

I am working on an app in which I have implemented the live video broadcasting, and have a feature to place a live comment just like a Facebook live video feature. The problem I am facing is with EditTextView for comments. When Soft Keyboard appears on the screen It pushes the layout to the top.
I have tried to adjustResize, adjsutPan & adjust Nothing properties in Manifest. But these properties doesn't fulfill the UI requirement. What I want is to just move EditTextView to the top of Soft Keyboard and the rest of the layout as it is.
Layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:background="#color/white"
android:clickable="true">
<org.webrtc.SurfaceViewRenderer
android:id="#+id/camera_view_renderer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:drawingCacheQuality="high"
android:fitsSystemWindows="true" />
<RelativeLayout
android:id="#+id/top_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:clipChildren="false"
android:clipToPadding="false">
<View
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#drawable/top_gradient" />
<include
android:id="#+id/headerLayout"
layout="#layout/header_layout" />
<com.lts.localee.customViews.LTextView
android:id="#+id/my_points"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/headerLayout"
android:gravity="center"
android:text=""
android:textColor="#color/white"
android:textSize="16dp" />
<com.lts.localee.customViews.PointsRangeComponent
android:id="#+id/points_range_component"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="#+id/headerLayout"
android:layout_marginBottom="120dp" />
<View
android:id="#+id/_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#AA2f3c43"
android:visibility="gone" />
<FrameLayout
android:id="#+id/livePredQuestionGameSubBaseContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false" />
<com.lts.localee.customViews.LTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginTop="100dp"
android:background="#drawable/rounded_button_prediction_pressed"
android:gravity="center"
android:minWidth="60dp"
android:padding="10dp"
android:text="sadas"
android:textColor="#color/white"
android:textSize="18dp"
android:visibility="gone" />
</RelativeLayout>
<com.lts.localee.customViews.TriviaCommentComponent
android:id="#+id/comments_component"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:visibility="visible"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</RelativeLayout>
Please help me out to solve this issue. Thanks
use android:windowSoftInputMode="adjustPan|adjustResize" inside your manifest
If android:windowSoftInputMode="adjustPan|adjustResize didn't help you, I think it's better to use <ScrollView> in your XML file

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>

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

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")

Making a button transparent Android?

How do I get rid of the white bit around the button? I don't want the button transparent, but I want the white bit around it. I've got Google Maps behind the button.
I've tried android:background="#android:color/transparent", on the Button, but it's only the button that becomes transparent (not the white bit around it).
How do I do this in XML?
<LinearLayout 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:orientation="vertical"
tools:context=".MyLocation" >
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#android:color/transparent"
android:gravity="center" >
<Button
android:id="#+id/filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="filterMenu"
android:text="#string/filter_button" />
</FrameLayout>
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</LinearLayout>
How about setting the background of RelativeLayout to transparent?
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent" >
<Button
android:id="#+id/filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:onClick="filterMenu"
android:text="#string/filter_button"
/>
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
And why not using FrameLayout anyway? It's better in performance than RelativeLayout.
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#android:color/transparent" >
<Button
android:id="#+id/filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="filterMenu"
android:text="#string/filter_button"
/>
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</FrameLayout>
try this:
MybuttonName.getBackground().setAlpha(0);
0= Completely transparent.
255 Completely opaque.
How about this.
Button filter = (Button) findViewById(R.id.filter);
filter.setBackgroundColor(Color.TRANSPARENT);
try this
android:background="#android:color/transparent"

How to handle nested FrameLayout properly

I am using FrameLayouts to overlap image over image, but I can't understand in this particular scenario where my inner FrameLayout doesn't show at the front of another image. Here's the theory:
and here's the actual thing:
So here's my XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/mypage_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="#+id/frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/cover_photo"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_marginTop="120dp"
android:scaleType="fitXY"
android:src="#CCFF0000" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/cover_photo" >
<ImageView
android:layout_width="105dp"
android:layout_height="90dp"
android:layout_below="#id/cover_photo"
android:adjustViewBounds="true"
android:src="#color/aqua"
android:translationY="-45dp" />
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginLeft="15dp"
android:src="#color/green"
android:translationY="-40dp" />
</FrameLayout>
</RelativeLayout>
</FrameLayout>
Have I placed the inner FrameLayout wrong? I don't know how what to do anymore.
Any help will be deeply appreciated. Thanks!
It is because your FrameLayout has this line: android:layout_below="#id/cover_photo". You can have FrameLayout like this:
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="-40dp"
android:layout_alignBottom="#id/cover_photo" >

Categories

Resources