Added underscroll tracking within ForecastFragment for elevation control.
This commit is contained in:
@@ -25,10 +25,13 @@ import android.net.Uri;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.support.design.widget.AppBarLayout;
|
||||||
|
import android.support.design.widget.CoordinatorLayout;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
import android.support.v4.content.CursorLoader;
|
import android.support.v4.content.CursorLoader;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
|
import android.support.v4.view.ViewCompat;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
@@ -219,6 +222,24 @@ public class ForecastFragment extends Fragment implements LoaderManager.LoaderCa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final AppBarLayout appbarView = (AppBarLayout)rootView.findViewById(R.id.appbar);
|
||||||
|
if (null != appbarView) {
|
||||||
|
ViewCompat.setElevation(appbarView, 0);
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||||
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
@Override
|
||||||
|
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||||
|
if (0 == mRecyclerView.computeVerticalScrollOffset()) {
|
||||||
|
appbarView.setElevation(0);
|
||||||
|
} else {
|
||||||
|
appbarView.setElevation(appbarView.getTargetElevation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If there's instance state, mine it for useful information.
|
// If there's instance state, mine it for useful information.
|
||||||
// The end-goal here is that the user never knows that turning their device sideways
|
// The end-goal here is that the user never knows that turning their device sideways
|
||||||
// does crazy lifecycle related things. It should feel like some stuff stretched out,
|
// does crazy lifecycle related things. It should feel like some stuff stretched out,
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||||
app:elevation="0dp">
|
app:elevation="@dimen/appbar_elevation">
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<android.support.v7.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
@@ -46,11 +46,9 @@
|
|||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:contentDescription="@string/app_name"
|
android:contentDescription="@string/app_name"
|
||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
android:src="@drawable/ic_logo"
|
android:src="@drawable/ic_logo"/>
|
||||||
app:layout_scrollFlags="scroll|enterAlways" />
|
|
||||||
</android.support.v7.widget.Toolbar>
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
|
|
||||||
</android.support.design.widget.AppBarLayout>
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
|
|||||||
Reference in New Issue
Block a user