我想用动画android调整视图的大小,而又不变形视图内的内容。具体来说,我想在Google地图中按一个群集图标,调整地图片段的大小并显示一个列表视图,这是我的代码
public void showDataView(){
RelativeLayout dataLinearLayout = getView().findViewById(R.id.dataLinearLayout);
View map = getView().findViewById(R.id.map);
if(isAnimationOn == 0) {
isAnimationOn = 1;
Animation anim = AnimationUtils.loadAnimation(getContext(), R.anim.minimize_maps);
anim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
map.startAnimation(anim);
Animation anim2 = AnimationUtils.loadAnimation(getContext(), R.anim.maximize_maps);
anim2.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
isAnimationOn = 1;
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
dataLinearLayout.startAnimation(anim2);
}
}
这是动画XML
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:fillAfter="true">
<scale android:fromXScale="1.0" android:toXScale="1.0"
android:fromYScale="1.0" android:toYScale="0.5"
android:pivotX="50%p" android:pivotY="0%p"
android:duration="250" />
</set>
查看代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="100"
android:orientation="vertical">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="100"
tools:context="com.viralandroid.googlemapsandroidapi.MapsActivity" />
<RelativeLayout
android:id="@+id/dataLinearLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50">
</RelativeLayout>
</LinearLayout>
这就是它的工作方式
如果您知道什么,请帮助我!