根据截图我想实现以下 ScreenUI (Android API >= 10):
您有 aGoogleMapsSupportFragement
和 a ListView
,它们共享 View 的剩余高度(height
在应用程序启动时计算,并且应用程序仅在其中运行PortraitMode
)
Container的行为ListView
应该类似于 Android-Notification Menu,因此用户可以将 List 滑入和滑出,但如果用户释放视图(触摸),动画就会开始。
到目前为止,我实现了由红线 ( ) 划分的两个LinearLayout
(Map
和)。我设法在点击红线时显示/隐藏 ListView,但如果我隐藏 ListView,它看起来很奇怪,因为地图被重绘并留下黑色空间..ListView
LinearLayout
问题是:什么s best way to implement (LinearLayout? Fragments?)? Do you know examples for the
onTouchBehaviour`(类似于打开Notication Menu)?
这是我的实现:
//function is triggered at click on the redline-button
private void toggleOverlayList(){
//TEST CASE API >= 11
int mListHeight = ((LinearLayout) findViewById(R.id.map_list)).getLayoutParams().height;
Log.i(DEBUG,"toggleOverlayList() -> currentHeight:" + mListHeight );
if(mListHeight == 0){
((LinearLayout) findViewById(R.id.map_wrapper)).getLayoutParams().height = mDisplayHeight;
((LinearLayout) findViewById(R.id.map_list)).getLayoutParams().height = mDisplayHeight;
((LinearLayout) findViewById(R.id.main_screen)).requestLayout();
}
else{
((LinearLayout) findViewById(R.id.map_wrapper)).getLayoutParams().height = 2* mDisplayHeight;
((LinearLayout) findViewById(R.id.map_list)).getLayoutParams().height = 0;
((LinearLayout) findViewById(R.id.main_screen)).requestLayout();
}
}
布局.xml
<LinearLayout
android:id="@+id/main_screen"
android:animateLayoutChanges="true"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/map_wrapper">
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/map_seperator"
android:layout_height="20dp" >
</LinearLayout>
<LinearLayout
android:id="@+id/map_list">
<ListView
android:id="@+id/listView1" >
</ListView>
</LinearLayout>
</LinearLayout>