无论我做什么,我都无法让它发挥作用。我有一个方法来设置视图标题的布局(这实际上是整个视图)...
private KenBurnsSupportView mHeaderSupportView;
private View mHeader;
private int mMinHeaderHeight;
private int mHeaderHeight;
private int mMinHeaderTranslation;
private int mActionBarHeight;
private boolean mResised = false;
private void setHeader(View fragmentView) {
mMinHeaderHeight = getResources().getDimensionPixelSize(R.dimen.min_header_height);
mHeaderHeight = getResources().getDimensionPixelSize(R.dimen.header_height);
mActionBarHeight = mUtils.getActionBarHeight(mActionBarHeight);
mMinHeaderTranslation = -mMinHeaderHeight + mActionBarHeight;
mHeaderSupportView = (KenBurnsSupportView) fragmentView.findViewById(R.id.song_header_support_view);
mHeader = fragmentView.findViewById(R.id.song_header);
mHeaderSupportView.setImageViews(mPlayList.getPlImageView(), mPlayList.getPlSongs().get(0).getmImageView());
}
这使用了这个视图:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:widget="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/song_header"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:transitionName="MyTransition"
android:layout_width="match_parent"
android:layout_height="@dimen/header_height"
android:id="@+id/pl_artwork"
android:scaleType="centerCrop"
android:src="@drawable/ic_user_background"
android:tint="@color/colorPrimary40Transparent"/>
<TextView
android:id="@+id/pl_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/pl_title_str"
android:padding="16dp"
android:textSize="24sp"
android:textColor="#FFFFFF"
android:maxLines="1"
android:ellipsize="end"
android:layout_gravity="end"
android:layout_alignBottom="@+id/pl_artwork"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<GridView
android:id="@+id/song_grid_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnWidth="150dp"
android:numColumns="2"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="3dp"
android:paddingStart="3dp"
android:paddingEnd="1dp"
android:paddingBottom="1dp"
android:layout_marginTop="@dimen/header_height"
android:horizontalSpacing="1dp"
android:verticalSpacing="1dp"
android:stretchMode="none"/>
<View
android:layout_below="@id/pl_artwork"
android:layout_width="fill_parent"
android:layout_height="5dip"
android:background="@drawable/drop_shadow"/>
<com.android.APPPACKEGE.widgets.CircleButton
android:id="@+id/song_play_fab"
widget:circle_icon="@android:drawable/ic_media_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
widget:circle_color="@color/colorPrimary"
android:layout_gravity="end"
android:padding="16dp"
android:layout_marginEnd="44dp"
android:layout_marginRight="44dp"
android:layout_marginTop="160dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<com.android.APPPACKEGE.ui.songheaderlib.KenBurnsSupportView
android:id="@+id/song_header_support_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"/>
</RelativeLayout>
我做什么我不能让gridView结束它在设备底部的视图:
![滚动结束于屏幕的一半] [1]
http://i.stack.imgur.com/lBKiA.gif
这是onScroll部分,所有这些都发生了:
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
int scrollY = mUtils.getScrollY(view, mHeaderHeight);
ViewHelper.setTranslationY(mHeader, Math.max(-scrollY, mMinHeaderTranslation));
继承人getScrollY方法:
public int getScrollY(AbsListView view, int mHeaderHeight) {
View c = view.getChildAt(0);
if (c == null) {
return 0;
}
int firstVisiblePosition = view.getFirstVisiblePosition();
int top = c.getTop();
int headerHeight = 0;
if (firstVisiblePosition >= 1) {
headerHeight = mHeaderHeight;
}
return (-top + firstVisiblePosition * c.getHeight() + headerHeight) + 48;
}
我已尝试过所有内容,甚至在gridView的所有父级上设置固定的770dp(570屏幕大小+标题200dp大小)。那不起作用......
我做错了什么?