Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gradient to preview images in toolbar #5634

Merged
merged 1 commit into from
Mar 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
Expand All @@ -49,6 +50,7 @@
public abstract class ToolbarActivity extends BaseActivity {
private ProgressBar mProgressBar;
private ImageView mPreviewImage;
private FrameLayout mPreviewImageContainer;
private LinearLayout mInfoBox;
private TextView mInfoBoxMessage;

Expand Down Expand Up @@ -79,6 +81,7 @@ protected void setupToolbar(boolean useBackgroundImage) {
mInfoBoxMessage = findViewById(R.id.info_box_message);

mPreviewImage = findViewById(R.id.preview_image);
mPreviewImageContainer = findViewById(R.id.preview_image_frame);

ThemeUtils.colorStatusBar(this, primaryColor);

Expand Down Expand Up @@ -197,8 +200,8 @@ public void setProgressBarVisibility(int visibility) {
* @param visibility visibility of the preview image
*/
public void setPreviewImageVisibility(int visibility) {
if (mPreviewImage != null) {
mPreviewImage.setVisibility(visibility);
if (mPreviewImage != null && mPreviewImageContainer != null) {
mPreviewImageContainer.setVisibility(visibility);
}
}

Expand Down
13 changes: 13 additions & 0 deletions src/main/res/drawable/preview_image_gradient_shape.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<gradient
android:angle="270"
android:endColor="#00000000"
android:startColor="#00000000"
android:centerColor="#00000000" />

<corners android:radius="0dp" />

</shape>
21 changes: 16 additions & 5 deletions src/main/res/layout/toolbar_standard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,24 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">

<ImageView
android:id="@+id/preview_image"
<FrameLayout
android:id="@+id/preview_image_frame"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_drawer_header_height"
android:contentDescription="@string/preview_image_description"
android:scaleType="centerCrop"
android:visibility="gone" />
android:visibility="gone">

<ImageView
android:id="@+id/preview_image"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_drawer_header_height"
android:contentDescription="@string/preview_image_description"
android:scaleType="centerCrop" />

<View
android:layout_width="match_parent"
android:layout_height="@dimen/nav_drawer_header_height"
android:background="@drawable/preview_image_gradient_shape" />
</FrameLayout>

<androidx.appcompat.widget.Toolbar
android:id="@id/toolbar"
Expand Down