我試圖改變RelativeLayout作爲用戶滾動的高度,所以它順利地向上移動。這是有點工作,但它的閃爍和閃爍。更改RelativeLayout高度,因爲用戶在滾動視圖中滾動
我試圖使用setTranslationY,但不會使用RelativeLayout移動滾動視圖。
int top = mScrollView.getScrollY();
int maxRelative = formulas.dpToPx(250);
int actualRelative = (int)((1.0-((float)top)/300.0)*((float)maxRelative));
RelativeLayout.LayoutParams layout_description = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
actualRelative);
mCollapsingLayout.setLayoutParams(layout_description);
mCollapsingLayout.requestLayout();
這是它的外觀
如果你有更好的想法如何收縮的RelativeLayout爲您滾動,它的讚賞。
編輯:這是我的XML
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:id="@+id/collapsing.view">
<ImageView
android:id="@+id/collapsing.view.image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/theflash"
android:tint="#7F000000"
android:scaleType="centerCrop"/>
<ImageButton
android:id="@+id/favorite.button"
android:layout_width="70dp"
android:layout_height="70dp"
android:background="?android:attr/selectableItemBackground"
android:scaleType="fitCenter"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="30dp"
android:src="@drawable/favorite_button"
/>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:paddingBottom="30px">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="The Flash"
android:textColor="#fff"
android:textSize="25sp"
android:layout_centerInParent="true"
/>
</FrameLayout>
</RelativeLayout>
<ScrollView
android:id="@+id/detail.scrollview"
android:layout_below="@+id/collapsing.view"
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
你可以分享你的佈局XML文件是正確的? – Alex
是的,它在現在的主帖:) – Bartando
你想調整整個'collapsing.view'或試圖添加視差效果圖像? – Alex