有什么方法可以隐藏视图而不使视图上方闪烁?
我正在尝试在 GONE
下隐藏视图。将其可见性设置为 MapView
后, MapView
会闪烁。由于必须动态添加更多标记,因此无法将bottomView
和FrameLayout
保留在bottomView
中,因为<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true">
<com.myapp.widgets.MapPlacePicker
android:id="@+id/lay_fr_map_inc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/options_layout" />
<LinearLayout
android:id="@+id/options_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:animateLayoutChanges="true"
android:background="#FFFFFF"
android:orientation="vertical"
android:visibility="visible">
<com.myapp.widgets.FontTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:text="Please select a location!!"
android:textAppearance="@android:style/TextAppearance.Small" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.aigestudio.wheelpicker.WheelPicker
android:id="@+id/main_option_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="0.5"
app:wheel_atmospheric="true"
app:wheel_curved="false"
app:wheel_item_space="15dp"
app:wheel_item_text_color="#ffafafaf"
app:wheel_item_text_size="12dp"
app:wheel_selected_item_text_color="@color/colorPrimary"
app:wheel_visible_item_count="3" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
会将这些标记隐藏在小尺寸的屏幕中。
布局:
TranslationAnimation
输出:
我也尝试过 int fromY = (visibility == View.GONE) ? 0 : optionLayout.getHeight();
int toY = (visibility == View.GONE) ? optionLayout.getHeight() : 0;
if (visibility == View.VISIBLE) {
optionLayout.setVisibility(visibility);
}
TranslateAnimation animate = new TranslateAnimation(
0, // fromXDelta
0, // toXDelta
fromY, // fromYDelta
toY); // toYDelta
animate.setDuration(1000);
animate.setInterpolator(new AccelerateDecelerateInterpolator());
//animate.setFillAfter(false);
animate.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
if (visibility == View.GONE)
optionLayout.setVisibility(visibility);
optionLayout.clearAnimation();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
optionLayout.startAnimation(animate);
,但是没有运气。它显示出比以前更多的灰色空间。
body{color:#fff; font: 1em/1.6em 'Open Sans', sans-serif;}
答案 0 :(得分:1)
在该动画中我看不到任何闪烁;如果要避免lay_fr_map_inc
的垂直调整大小行为,则可以删除此属性:
android:layout_above="@+id/options_layout"
...并且可能将高度设为match_parent
。然后,lay_fr_map_inc
会保持全高,但是底部options_layout
会在出现时被其隐藏(而不是向上倾斜)。
这样做时,请不要忘记更改地图填充,这样您就不会模糊Google徽标(这违反了rules):setPadding()