为什么屏幕的ImageView没有绘制:
问题描述:
我需要在包含RecylerView
和ImageView
的布局上创建反弹动画。为了简化这里的解释是我目前的布局示意图:为什么屏幕的ImageView没有绘制:
的RecyclerView
(红)采取所有屏幕大小,并在其下我位置的ImageView
(绿色)就是不见在开始时。这两个视图包含在一个垂直方向上的LinearLayout
(蓝色)。
我想要做的是将LinearLayout
向上移动50dp,然后用反弹动画将其放回,以便图像视图仅在此动画中可见。
的问题是,当我提出的LinearLayout
与此代码:
mLayout.postDelayed(new Runnable() {
@Override
public void run() {
mLayout.animate().y(-500f);
}
}, 1000);
的ImageView的不显示,更多的时候我用DDMS和移动动画后,即可获取XML布局的快照,在它看起来像图像甚至不是布局的一部分。
UPDATE:的XML布局:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical"
android:animateLayoutChanges="true"
android:theme="@style/AppTheme.MyTopics.Theme"
tools:mContext=".ui.fragments.MyTopicsFragment">
<include
android:id="@+id/toolbar_container"
layout="@layout/toolbar_timeline_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:id="@+id/layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@id/toolbar_container">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager
android:id="@+id/vertical_recycler_view"
style="@style/NoOverScrollStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
app:rvp_singlePageFling="true"/>
</android.support.v4.widget.SwipeRefreshLayout>
<ImageView
android:id="@+id/first_time_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:layout_below="@+id/swipe_refresh"
android:background="@android:color/holo_green_dark"
android:src="@drawable/drawable_image_tutorial_background"/>
</LinearLayout>
<com.shellanoo.newsbot.ui.views.GeneralErrorView
android:id="@+id/no_data_errors_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:gev_no_data_view_layout="@layout/view_no_data_timeline"/>
<com.shellanoo.newsbot.ui.views.ProgressWheel
android:id="@+id/loading_pb"
style="@style/AppTheme.ProgressBar.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone"/>
<ImageView
android:id="@+id/my_topics_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_gravity="bottom|left"
android:paddingBottom="20dp"
android:paddingLeft="24dp"
android:paddingRight="30dp"
android:paddingTop="20dp"
android:visibility="gone"
app:srcCompat="@drawable/profile_main"
tools:visibility="visible"/>
<ImageView
android:id="@+id/add_topics_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_gravity="bottom|right"
android:paddingBottom="20dp"
android:paddingLeft="30dp"
android:paddingRight="24dp"
android:paddingTop="20dp"
android:visibility="gone"
app:srcCompat="@drawable/plus_main"
tools:visibility="visible"/>
<com.shellanoo.newsbot.ui.views.NewStoriesIndicatorView
android:id="@+id/new_items_tip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:padding="8dp"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"
tools:text="5 new items"/>
</RelativeLayout>
是否有人知道为什么,这可怎么固定?
在此先感谢。
答
尝试像XML代码可能是你提供的recyclerview match_parent属性此
<RelativeLayout
android:id="@+id/layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="200dp">
<com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager
android:id="@+id/vertical_recycler_view"
style="@style/NoOverScrollStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
app:rvp_singlePageFling="true"
android:minHeight="200dp"/>
</android.support.v4.widget.SwipeRefreshLayout>
<ImageView
android:id="@+id/first_time_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:layout_below="@+id/swipe_refresh"
android:background="@android:color/holo_green_dark"
android:src="@drawable/drawable_image_tutorial_background"/>
</RelativeLayout>
+0
尝试使用带有wrap_content高度的SwipeRefreshLayout的RelativeLayout,但结果相同。图像不显示。 –
份额,就必须限制recylcerview的高度,使用的RelativeLayout/LinearLayout中父 – SaravInfern
你应该使用的RelativeLayout作为父母,更轻,它可能有助于解决您的重叠问题,请问您可以发布xml布局吗? – Cata
@SaravInfern布局添加。 –