4

MapFragment を含むビューがあります

私のmainViewPanelは次のようになります

<LinearLayout
android:id="@+id/main_view_panel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:orientation="horizontal">

<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
class="com.google.android.gms.maps.SupportMapFragment"
map:cameraTargetLat="40.72"
map:cameraTargetLng="-74.00"
map:cameraZoom="8"/>

</LinearLayout>

私の翻訳コードは次のようになります

TranslateAnimation anim = new TranslateAnimation(0, 500, 0, 0);
anim.setFillAfter(true);
anim.setDuration(250);
mainViewPanel.startAnimation(anim);

ビューの残りの部分はアニメーション化されますが、マップはそのままです。メイン ビュー ウィンドウが移動しているようで、マップの右側にさらに多くのものが表示されますが、マップ自体は視覚的に移動していません。アニメーションは、TextView などの他のビューでも問題なく機能します。

4

2 に答える 2

3

これは、Androidの新しいバージョンで動作します

mainViewPanel.animate().translationX(500);
于 2013-01-19T20:29:13.173 に答える
0

これは、SurfaceView を使用して新しいマップ API が作成され、アニメーションが実行できないためです。

私が見つけた一時的なパッチは次のとおりです。 MapFragment に対して透過的なビューを使用します。そのため、MapFragment をアニメーション化すると、それとともにアニメーション化され、その時点でマップは非表示になります。

例として:

<RelativeLayout
android:id="@+id/main_view_panel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
class="com.google.android.gms.maps.SupportMapFragment"
map:cameraTargetLat="40.72"
map:cameraTargetLng="-74.00"
map:cameraZoom="8"/>

 <ImageView
            android:id="@+id/map_overlay"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#00000000" />

</RelativeLayout>

これを試して。それはうまくいくはずです。

注 : ビューをアニメーション化するときに、可視性を変更する必要がある場合があります。アニメーションの後にマップを表示したい場合は、オーバーレイ ビューを非表示にする必要があり、アニメーションを開始したい場合は、オーバーレイ ビューを再表示する必要があります。ただし、非表示/非表示のプロセスがアニメーションの完了後にのみ実行されるようにする必要があります。

アニメーションの手順:

  • アニメーションを開始する前に、オーバーレイ ビューを再表示します
  • アニメーションの完了後、少し遅れてオーバーレイ ビューを非表示にすることを意味します

わたしにはできる。

于 2013-03-07T14:56:42.750 に答える