これは、this iOSに関するAndroid対応版です。Android - 地図付き正方形のようなScrollView +リスト
画面の約20%(ActionBar ...の下)にMapViewを含むビューを作成しようとすると、画面の残りの部分はスクロールダウンしてMapViewの上に重なり、隠すScrollViewですそれ。要するにFourSquareのAndroidアプリのように。 アイデア
これは、this iOSに関するAndroid対応版です。Android - 地図付き正方形のようなScrollView +リスト
画面の約20%(ActionBar ...の下)にMapViewを含むビューを作成しようとすると、画面の残りの部分はスクロールダウンしてMapViewの上に重なり、隠すScrollViewですそれ。要するにFourSquareのAndroidアプリのように。 アイデア
私はAndroidSlidingUpPanel(多くのこのプロジェクトのおかげで)に基づいて実装しました。
例と詳細http://android.amberfog.com/?p=915 ソースコード:https://github.com/dlukashev/AndroidSlidingUpPanel-foursquare-map-demo
あなたは自分のxmlファイルにLinearLayout
を埋め込むScrollView
を宣言することができ、それは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
属性に
を指定することにより、各要素のサイズを設定することができますEDIT IvanDanDo、私たちの議論に続いて、私はあなたが望むことができるこのリンクを見つけました(確かに私は試していませんでした):Android: Have an arbitrary View slide under another View like the software keyboard does
'MapFragment'' layout_weight' = 1と 'LinearLayout'を与えました。 'layout_weight' = 3ですが、私が見るのは画面全体と下のどこかにあるリスト、ヒントです。私の地図の上にもスクロールしません。 – OferM
これは奇妙なことですが、私のアプリにはほとんど同じコードがあります。たとえば、マップを 'ImageView'と置き換えた場合、それはスクロールしますか?また、最初の 'LinearLayout'の' weightSum'属性を4に指定できますか? – jbihan
これはImageViewに変更されました。私のリストは十分に大きくないので、スクロールする必要はありませんでした。 (ダム)。しかし、今私がスクロールすると、 'ImageView' /' Map'がちょうどロールアップします。リストが最終的にオーバーラップのようにスクロールして完全に隠れるので、トップに固執して欲しいです。どのようにその効果を得るのですか? – OferM
LAST UPDATE
<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);
これはほとんど理想的ですが、それは動作します。私はそれが誰かを助けることを願っています。
:もっと良い解決策があれば教えてください – user965071
これは私が今までに見つけた最良の解決策です。私は画面全体に合わせてマップを開く非表示フレームにクリックハンドラを追加しました。 – OferM
作成したレイアウトを共有していただけますか? – user965071
最も簡単な解決策は、あなたのスライダーのコンテンツ(SlidingUpPanelの2番目のパラメータ)にマージンを追加し、フェージング背景を削除することです。すべてXMLから実行されます。
[http://stackoverflow.com/questions/25487861/android-maps-markers-bounds-at-the-center-of-top-half-of-map-area](http://stackoverflow.com)/question/25487861/android-maps-marker-bounds-of-the-map-of-map-areaの上半分) –