首先,我知道将mapview或listview保留在scrollview中并不好。但我希望设计如下页面。
我尝试了setListViewHeightBasedOnchildren
方法。由于我的列表视图是动态的,所以很迟钝。 mapview,我无法向上和向下滚动,当我滚动时它会闪烁。
这样做的最佳方式是什么?
我可以将所有视图添加为listview标题吗? mapview很重!!我可以将该视图作为标题添加到列表视图吗?
以下是源代码:
<?xml version="1.0" encoding="utf-8"?>
<include
android:id="@+id/bottomMenu"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
layout="@layout/bottom_menu" />
<include
android:id="@+id/topMenu"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
layout="@layout/top_menu" />
<ScrollView
android:id="@+id/mainScrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/bottomMenu"
android:layout_below="@id/topMenu"
android:fadingEdge="vertical"
android:fadingEdgeLength="20dip"
android:fillViewport="true"
android:scrollbars="none" >
<TableLayout
android:id="@+id/linearShopInfo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- Images and its header -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dip" >
<ImageView
android:id="@+id/imgStoreImage"
android:layout_width="150dip"
android:layout_height="165dip"
android:adjustViewBounds="true"
android:background="@drawable/rounded_white_border"
android:contentDescription="@string/app_name"
android:scaleType="fitXY" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left|center"
android:orientation="vertical" >
<!-- style="@style/CustomRatingBar" -->
<RatingBar
android:id="@+id/ratingShops"
style="@style/CustomRatingBar"
android:layout_width="wrap_content"
android:layout_height="25dip"
android:layout_margin="5dip"
android:clickable="false"
android:focusable="false"
android:isIndicator="true"
android:numStars="5"
android:stepSize="0.5" />
<TextView
android:id="@+id/txtReviewCount"
style="@android:style/TextAppearance.Medium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dip"
android:singleLine="true"
android:textColor="@color/black" />
<CheckBox
android:id="@+id/chkFavoriteShop"
style="@android:style/TextAppearance.Medium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:button="@drawable/icon_star_empty"
android:drawablePadding="5dip"
android:text="@string/favorite_store" />
<TextView
android:id="@+id/txtConnect"
style="@android:style/TextAppearance.Medium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dip"
android:singleLine="true"
android:text="@string/share"
android:textColor="@color/black" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:orientation="horizontal" >
<ImageView
android:id="@+id/btnFaceBook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:contentDescription="@string/app_name"
android:padding="3dip"
android:src="@drawable/icon_facebook" />
<ImageView
android:id="@+id/btnTwitter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:contentDescription="@string/app_name"
android:padding="3dip"
android:src="@drawable/icon_twitter" />
<ImageView
android:id="@+id/btnGooglePlus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:contentDescription="@string/app_name"
android:padding="3dip"
android:src="@drawable/icon_google_plus" />
<ImageView
android:id="@+id/btnShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:contentDescription="@string/app_name"
android:padding="3dip"
android:src="@drawable/icon_share" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="3dip"
android:layout_marginTop="2dip"
android:background="@drawable/line" />
<TextView
android:id="@+id/txtAboutStoreCaption"
style="@android:style/TextAppearance.Large"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dip"
android:singleLine="true"
android:text="@string/about_the_store"
android:textColor="@color/black" />
<TextView
android:id="@+id/txtAboutStore"
style="@android:style/TextAppearance.Medium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dip"
android:textColor="@color/black" />
<View
android:layout_width="fill_parent"
android:layout_height="3dip"
android:layout_marginTop="2dip"
android:background="@drawable/line" />
<TextView
android:id="@+id/txtMapAndLocationCaption"
style="@android:style/TextAppearance.Large"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dip"
android:singleLine="true"
android:text="@string/map_and_location"
android:textColor="@color/black" />
<FrameLayout
android:id="@+id/mMapFrame"
android:layout_width="fill_parent"
android:layout_height="230dip" >
<android.support.v4.view.ViewPager
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</android.support.v4.view.ViewPager>
<fragment
android:id="@+id/mMapView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
class="com.google.android.gms.maps.SupportMapFragment"
android:background="@android:color/transparent" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent" />
</FrameLayout>
<View
android:layout_width="fill_parent"
android:layout_height="3dip"
android:layout_marginTop="2dip"
android:background="@drawable/line" />
<TextView
android:id="@+id/txtShopAddress"
style="@android:style/TextAppearance.Medium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="8dip"
android:singleLine="true"
android:text="@string/coupons"
android:textColor="@color/black" />
<View
android:layout_width="fill_parent"
android:layout_height="3dip"
android:layout_marginTop="2dip"
android:background="@drawable/line" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dip"
android:layout_marginTop="4dip"
android:orientation="horizontal"
android:padding="3dip" >
<TextView
android:id="@+id/txtShopWebAddress"
style="@android:style/TextAppearance.Medium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="@drawable/icon_mouse"
android:drawablePadding="4dip"
android:gravity="center"
android:padding="5dip"
android:paddingLeft="25dip"
android:singleLine="true"
android:text="@string/view_website"
android:textColor="@color/blue" />
<View
android:layout_width="2dip"
android:layout_height="30dip"
android:layout_marginTop="2dip"
android:background="@color/blue" />
<TextView
android:id="@+id/txtShopNumber"
style="@android:style/TextAppearance.Medium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="@drawable/icon_phone"
android:drawablePadding="4dip"
android:gravity="center"
android:padding="5dip"
android:paddingLeft="25dip"
android:singleLine="true"
android:textColor="@color/blue" />
</LinearLayout>
<LinearLayout
android:id="@+id/linOffers"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/txtRewards"
style="@android:style/TextAppearance.Medium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/dark_grey"
android:gravity="center"
android:paddingBottom="12dip"
android:paddingTop="12dip"
android:text="@string/rewards"
android:textColor="@color/white" />
<View
android:layout_width="1dip"
android:layout_height="match_parent"
android:background="@color/black" />
<TextView
android:id="@+id/txtDeals"
style="@android:style/TextAppearance.Medium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/dark_grey"
android:gravity="center"
android:paddingBottom="12dip"
android:paddingTop="12dip"
android:text="@string/deals"
android:textColor="@color/white" />
<View
android:layout_width="1dip"
android:layout_height="match_parent"
android:background="@color/black" />
<TextView
android:id="@+id/txtCoupons"
style="@android:style/TextAppearance.Medium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/dark_grey"
android:gravity="center"
android:paddingBottom="12dip"
android:paddingTop="12dip"
android:singleLine="true"
android:text="@string/coupons"
android:textColor="@color/white" />
<View
android:layout_width="1dip"
android:layout_height="match_parent"
android:background="@color/black" />
<TextView
android:id="@+id/txtGiftCards"
style="@android:style/TextAppearance.Medium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/grey_deep_dark"
android:gravity="center"
android:paddingBottom="12dip"
android:paddingTop="12dip"
android:singleLine="true"
android:text="@string/gift_cards"
android:textColor="@color/black" />
</LinearLayout>
<TextView
android:id="@+id/txtRewardBalance"
style="@android:style/TextAppearance.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:gravity="center"
android:padding="5dip"
android:singleLine="true"
android:textColor="@color/black" />
<ListView
android:id="@+id/offerList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="30dip"
android:fadingEdge="vertical"
android:fadingEdgeLength="20dip"
android:footerDividersEnabled="false"
android:headerDividersEnabled="false"
android:scrollbarStyle="outsideOverlay" >
</ListView>
</LinearLayout>
<LinearLayout
android:id="@+id/linGiftCards"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/txtGiftCardBalance"
style="@android:style/TextAppearance.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:gravity="center"
android:padding="5dip"
android:singleLine="true"
android:textColor="@color/black" />
<TextView
android:id="@+id/txtAddToCard"
style="@android:style/TextAppearance.Medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:background="@drawable/btn_blue_full_size"
android:gravity="center"
android:padding="5dip"
android:text="@string/add_to_card"
android:textColor="@color/white" />
<TextView
android:id="@+id/txtGiveAGiftCard"
style="@android:style/TextAppearance.Medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="40dip"
android:layout_marginTop="10dip"
android:background="@drawable/btn_blue_full_size"
android:drawableLeft="@drawable/ic_gift_card"
android:drawablePadding="6dip"
android:gravity="center"
android:paddingLeft="30dip"
android:paddingRight="30dip"
android:text="@string/give_a_gift_card"
android:textColor="@color/white" />
</LinearLayout>
<TextView
android:id="@+id/txtNoOffersAvail"
style="@android:style/TextAppearance.Medium"
android:layout_width="fill_parent"
android:layout_height="150dip"
android:gravity="center"
android:textColor="@color/black" />
</TableLayout>
</ScrollView>