java - Android – MapFragment overlay button shadow, just like MyLocation button -


i'm struggling add shadow custom overlay button on google map. goal make custom button google's mylocation button. here's how app looks now:

enter image description here

layout.xml

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     xmlns:map="http://schemas.android.com/apk/res-auto"     android:layout_height="match_parent"     android:layout_width="match_parent"     style="@style/apptheme">      <fragment         android:layout_width="match_parent"         android:layout_height="match_parent"         android:id="@+id/map"         tools:context=".mapsactivity"         android:name="com.google.android.gms.maps.supportmapfragment"         android:layout_alignparentend="true"         android:layout_alignparentstart="true"         android:layout_alignparentbottom="true"         android:layout_alignparenttop="true" />       <imagebutton         android:layout_width="40dp"         android:layout_height="40dp"         android:id="@+id/button"         android:layout_alignparenttop="true"         android:layout_alignparentend="true"         android:layout_margintop="10dp"         android:layout_marginright="10dp"         android:src="@drawable/ic_search_black_24dp"         android:tint="@color/icon_gray"         android:onclick="searchbuttonclicked"         android:background="@drawable/mapbutton"         />      <linearlayout         android:layout_width="match_parent"         android:layout_height="match_parent">         <com.quinny898.library.persistentsearch.searchbox             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:id="@+id/searchbox"             />      </linearlayout>  </relativelayout> 

mapbutton.xml

<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android">     <item android:state_enabled="false">         <shape android:shape="rectangle">             <corners android:radius="1.3dp" />             <solid android:color="#55ffffff" />         </shape>     </item>     <item         android:state_pressed="true"         android:state_enabled="true">         <shape android:shape="rectangle">             <corners android:radius="1.3dp" />             <solid android:color="#ccb3b3b3" />         </shape>     </item>     <item         android:state_focused="true"         android:state_enabled="true">         <shape android:shape="rectangle">             <corners android:radius="1.3dp" />             <solid android:color="#a9ffffff" />         </shape>     </item>     <item android:state_enabled="true">         <shape android:shape="rectangle">             <corners android:radius="1.3dp" />             <solid android:color="#baffffff" />         </shape>     </item> </selector> 

i have tried changing android:elevation value on imagebutton. unfortunately, adding elevation value doesn't seem add shadow button. there way add shadow mapbutton drawable?

try code

    <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item> <layer-list> <item android:left="5dp" android:top="5dp"> <shape> <corners android:radius="3dp"/> <solid android:color="#d6d6d6"/> </shape> </item> <item android:bottom="2dp" android:right="2dp"> <shape> <gradient android:angle="270" android:endcolor="#dc5f0a" android:startcolor="#e68f54"/> <!--  <stroke android:width="1dp" android:color="#bababa" />  --> <corners android:radius="4dp"/> <padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp"/> </shape> </item> </layer-list> </item> </selector> 

i hope will.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

android - Go back to previous fragment -