Android:MapFragment没有移动动画
作者:互联网
我有一个包含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
解决方法:
这适用于较新版本的android
mainViewPanel.animate().translationX(500);
标签:android,android-animation,mapfragment 来源: https://codeday.me/bug/20190629/1329340.html