2016-07-28 36 views
2

我需要在包含RecylerViewImageView的佈局上創建反彈動畫。爲了簡化這裏的解釋是我目前的佈局示意圖:爲什麼屏幕的ImageView沒有繪製:

enter image description here

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> 

是否有人知道爲什麼,這可怎麼固定?

在此先感謝。

+0

份額,就必須限制recylcerview的高度,使用的RelativeLayout/LinearLayout中父 – SaravInfern

+0

你應該使用的RelativeLayout作爲父母,更輕,它可能有助於解決您的重疊問題,請問您可以發佈xml佈局嗎? – Cata

+0

@SaravInfern佈局添加。 –

回答

0

嘗試像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,但結果相同。圖像不顯示。 –