【发布时间】:2015-08-04 11:58:29
【问题描述】:
在我的应用程序中,我需要在谷歌地图上创建一个透明的列表视图。我正在使用切换按钮来打开和关闭列表视图。当列表视图可见时,它应该是透明的,以便谷歌地图应该是可见/半可见的。
这部分有三种布局。 1.custom_cluster_mapview.xml 2.底部布局.xml 3. map_list_view_row
-
custom_cluster_mapview.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" xmlns:materialdesign="http://schemas.android.com/apk/com.gc.materialdesign" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".map.MapView" > <LinearLayout android:id="@+id/myLinearLayout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/mapLayout" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" > <fragment android:id="@+id/mycustomemap" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.SupportMapFragment" /> </LinearLayout> <include layout="@layout/bottomlayout" /> </LinearLayout> </RelativeLayout> -
bottomlayout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/outerLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:weightSum="2" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <ToggleButton android:layout_width="40dp" android:layout_height="40dp" android:background="@drawable/up_arrow" android:textOff="" android:textOn="" android:id="@+id/toggleButtonListView" android:layout_gravity="center_horizontal" /> </LinearLayout> <LinearLayout android:id="@+id/mapListViewSlider" android:layout_width="match_parent" android:layout_height="wrap_content" android:visibility="gone" android:layout_weight="1.95" android:orientation="vertical"> <CheckBox android:id="@+id/sort_distance" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Sort By Distance"/> <ListView android:layout_width="match_parent" android:layout_height="wrap_content" android:dividerHeight="5dp" android:divider="@color/red" android:id="@+id/map_listview"/> </LinearLayout> </LinearLayout>
3. map_list_view_row.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp"
android:paddingBottom="12dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:weightSum="4"
android:id="@+id/linearLayout">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="@+id/map_list_view_tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="@string/label_name" />
<TextView
android:id="@+id/map_list_view_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/map_list_view_tv1"
android:text="abcde"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="@+id/map_list_view_tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_category" />
<TextView
android:id="@+id/map_list_view_category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/map_list_view_tv2"
android:text="abcde" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="@+id/map_list_view_tv3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_location" />
<TextView
android:id="@+id/map_list_view_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/map_list_view_tv3"
android:text="abcde" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="@+id/map_list_view_tv4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp"
android:text="@string/label_distance" />
<TextView
android:id="@+id/map_list_view_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/map_list_view_tv4"
android:text="abcde" />
</RelativeLayout>
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/map_list_view_imageView"
android:background="@drawable/med"
android:layout_marginTop="4dp"
android:layout_marginRight="16dp"
android:layout_alignParentRight="true"/>
</RelativeLayout>
以下是地图加载时的图片 http://i.stack.imgur.com/GtizG.png
屏幕底部有向上箭头按钮。我想让那个透明的背景。所以只有箭头是可见的,没有任何背景。当我单击箭头时,会显示 listView。如下所示
http://i.stack.imgur.com/CUFZz.png
如何让listView透明化,让google地图可见/半可见。
提前致谢。
【问题讨论】:
-
我不确定,但你可以试试:android:background="@null"
-
请将其添加到列表视图本身
-
Bhavesh N 给出了解决方案。它正在工作。\
-
太棒了 :D 会在我需要时记录下来
标签: android google-maps listview android-listview