我有一个包含 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