Skip to content

Instantly share code, notes, and snippets.

@B0yma
Last active April 20, 2019 17:50
Show Gist options
  • Save B0yma/189d39c6edb074f4748bae6f0dc7fcde to your computer and use it in GitHub Desktop.
Save B0yma/189d39c6edb074f4748bae6f0dc7fcde to your computer and use it in GitHub Desktop.
AppBarShadowDependency
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="#34000000"
android:endColor="#00000000"
android:angle="-90"
android:useLevel="false"
android:type="linear"/>
</shape>
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_marginBottom="3dp"
app:layout_constraintTop_toBottomOf="@id/custombar"
android:layout_height="wrap_content"
android:id="@+id/scrollview"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintEnd_toEndOf="parent" android:background="@color/colorPrimary">
<FrameLayout android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text="@string/large_text"/>
</FrameLayout>
</androidx.core.widget.NestedScrollView>
<ImageView
android:layout_width="match_parent"
android:background="@drawable/appbargrad"
app:layout_constraintTop_toBottomOf="@id/custombar"
android:layout_height="3dp" android:id="@+id/barshadow"
/>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
android:orientation="vertical" android:background="@color/colorPrimary"
android:id="@+id/custombar" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintEnd_toEndOf="parent">
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/textView6"
tools:layout_editor_absoluteX="191dp" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/textView5"
tools:layout_editor_absoluteX="191dp" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/textView4"
tools:layout_editor_absoluteX="191dp" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
scrollview.setOnScrollChangeListener { v: NestedScrollView?, scrollX: Int, scrollY: Int, oldScrollX: Int, oldScrollY: Int ->
barshadow.alpha = (scrollY/50f)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment