Googleマップのfragment
をscrollView
の中に使用しようとしていて、地図を表示できませんでした。 scrollView
を削除して、それをそのまま残すと、今地図が表示されます。私はなぜそれが理解できるようにしようとしているだけでなく、この断片をスクロールビューの最後に表示する方法があれば、scrollview内のGoogleマップの断片
8
A
答えて
1
<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="com.example.joe.goout.EventDetails">
<ImageView
android:src="@mipmap/park1"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:id="@+id/imageView"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/imageView"
android:id="@+id/scrollView"
android:fillViewport="false">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Medium Text"
android:id="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</ScrollView>
</RelativeLayout>
IはScrollView
にコンテンツを追加し、その後RelativeLayout
の内部コンテンツをラップすることによってそれを解決しました。
<ScrollView android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="@color/white"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:src="@mipmap/park1"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:id="@+id/imageView"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/shareBtn"
android:layout_above="@+id/textView"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="Medium Text"
android:textColor="@color/black"
android:padding="15dp"
android:layout_below="@id/imageView"
android:id="@+id/textView" />
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:name="com.google.android.gms.maps.SupportMapFragment"
class="com.google.android.gms.maps.SupportMapFragment"
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="210dp"
android:layout_below="@id/textView"
android:layout_marginBottom="40dp"
map:cameraZoom="13"
map:mapType="normal"
map:liteMode="true"
tools:context=".EventDetails"/>
</RelativeLayout>
</ScrollView>
2
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@mipmap/park1" />
<Button
android:id="@+id/shareBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:text="New Button" />
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/imageView"
android:padding="15dp"
android:text="Medium Text"
android:textColor="@color/black" />
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="fill_parent"
android:layout_height="210dp"
android:layout_below="@id/textView"
android:layout_marginBottom="40dp"
map:cameraZoom="13"
map:liteMode="true"
map:mapType="normal"
tools:context=".EventDetails" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
4
まず、あなたは以下のように、カスタムScrollView
クラスを作成する必要があります。
public class CustomScrollView extends ScrollView {
public CustomScrollView(Context context) {
super(context);
}
public CustomScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomScrollView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
final int action = ev.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
//Log.i("CustomScrollView", "onInterceptTouchEvent: DOWN super false");
super.onTouchEvent(ev);
break;
case MotionEvent.ACTION_MOVE:
return false; // redirect MotionEvents to ourself
case MotionEvent.ACTION_CANCEL:
// Log.i("CustomScrollView", "onInterceptTouchEvent: CANCEL super false");
super.onTouchEvent(ev);
break;
case MotionEvent.ACTION_UP:
//Log.i("CustomScrollView", "onInterceptTouchEvent: UP super false");
return false;
default:
//Log.i("CustomScrollView", "onInterceptTouchEvent: " + action);
break;
}
return false;
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
super.onTouchEvent(ev);
//Log.i("CustomScrollView", "onTouchEvent. action: " + ev.getAction());
return true;
}
}
その後ScrollView
の代わりにCustomScrollView
クラスを使用します。
<CustomScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scrollView">
</CustomScrollView>
完了です! :D
関連する問題
- 1. AndroidのGoogleマップの断片
- 2. スイッチング断片 - Googleマップ断片V2 - 活動が破棄されたエラー
- 3. は、各断片に断片
- 4. 断片内でスイッチする
- 5. 適切にナビゲーションドロワー活動フラグメントにGoogleマップの断片を使用する方法
- 6. Scrollviewが断片、アンドロイドで完全にスクロールしない
- 7. アクティビティの断片
- 8. どのようにアンドロイドにGoogleマップのタッチイベントを処理するために(断片内)
- 9. RecyclerView内の断片からTabBar
- 10. 断片)
- 11. 断片
- 12. Androidの断片:他のフラグメントからの断片を置換
- 13. Androidの断片は
- 14. その子断片
- 15. つの断片は、
- 16. ローダーの断片化 - 断片の漏れはありますか?
- 17. AppBarLayoutは断片
- 18. 違い、断片
- 19. 断片でFindViewbyID
- 20. 断片は
- 21. 断片OnClickListener
- 22. 断片クラス
- 23. 断片バックナビゲーション
- 24. 断片オーバーラップappbar
- 25. は断片
- 26. Androidの二つの断片
- 27. Androidの断片のビューステート
- 28. どのようにして、アンドロイドの断片内に断片を表示して隠すようにする
- 29. Androidの断片ですか?
- 30. 断片化FrameLayoutのアニメーションGONE
これはすでに応答されているようです:http://stackoverflow.com/questions/30525066/how-to-set-google-map-fragment-inside-scroll-view –
私の問題は、マップの断片scrollViewの内部に表示されていません。私は、Googleマップライトを使用しています、私は本当にスクロールビュー内に表示されていないマップがわからないが、私はscrollViewから削除したときすべてがうまくいく... –
あなたはnestedScrollViewを試しましたか?相対的な新しいhttps://developer.android.com/reference/android/support/v4/widget/NestedScrollView.html –