这是这个iOS问题的Android等价物。
试图在屏幕的大约 20% 处(在 ActionBar 下...)创建一个包含 MapView 的视图,而屏幕的其余部分是一个 ScrollView,当向下滚动时,它会在 MapView 顶部重叠并隐藏它。简而言之,就像 FourSquare 的 Android 应用程序。有任何想法吗?
这是这个iOS问题的Android等价物。
试图在屏幕的大约 20% 处(在 ActionBar 下...)创建一个包含 MapView 的视图,而屏幕的其余部分是一个 ScrollView,当向下滚动时,它会在 MapView 顶部重叠并隐藏它。简而言之,就像 FourSquare 的 Android 应用程序。有任何想法吗?
我已经基于AndroidSlidingUpPanel做了一个实现(非常感谢这个项目)。
详情http://android.amberfog.com/?p=915 源码示例:https ://github.com/dlukashev/AndroidSlidingUpPanel-foursquare-map-demo
最后更新
<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_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<fragment
android:id="@+id/map_fragment"
android:name="com.myapp.MapFragment"
android:layout_width="match_parent"
android:layout_height="fill_parent" />
<fragment
android:id="@id/list_fragment"
android:name="com.myapp.ListFragment"
android:layout_width="wrap_content"
android:layout_height="fill_parent" />
然后我在列表中添加一个不可见的标题,如下所示:
@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View view = inflater.inflate(R.layout.listview, container, false);
SwipeListView listView = (SwipeListView) view.findViewById(R.id.venue_list);
// An invisible view added as a header to the list and clicking it leads to the mapfragment
TextView invisibleView = new TextView(inflater.getContext());
invisibleView.setBackgroundColor(Color.TRANSPARENT);
invisibleView.setHeight(300);
invisibleView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
listener.moveToMapFragment();
}
});
listView.addHeaderView(invisibleView);
这并不理想,但它确实有效。我希望它可以帮助某人..
最简单的解决方案是为您的滑块内容添加边距(SlidingUpPanel 的第二个参数),然后移除褪色背景。全部从 XML 完成。
您可以在嵌入 a 的 xml 文件中声明ScrollView
a LinearLayout
,即嵌入 a MapView
:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:fillViewport="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
...... Your list and other stuff .......
</LinearLayout>
</LinearLayout>
</ScrollView>
layout_weight
然后你可以通过指定属性来设置每个元素的大小
编辑 IvanDanDo,在我们的讨论之后,我发现这个链接可能会做你想要的(虽然不确定,我没有尝试过):Android:在另一个视图下有一个任意视图幻灯片,就像软件键盘一样