mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Show toolbar shadow on pre-Lollipop
This commit is contained in:
@@ -28,6 +28,7 @@ import android.os.Bundle;
|
|||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.isoron.uhabits.commands.Command;
|
import org.isoron.uhabits.commands.Command;
|
||||||
@@ -132,7 +133,7 @@ abstract public class BaseActivity extends AppCompatActivity implements Thread.U
|
|||||||
if(toolbar == null) return;
|
if(toolbar == null) return;
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||||
toolbar.setElevation(UIHelper.dpToPixels(this, 6));
|
toolbar.setElevation(UIHelper.dpToPixels(this, 3));
|
||||||
|
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
@@ -182,4 +183,19 @@ abstract public class BaseActivity extends AppCompatActivity implements Thread.U
|
|||||||
getWindow().setStatusBarColor(darkerColor);
|
getWindow().setStatusBarColor(darkerColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostResume()
|
||||||
|
{
|
||||||
|
super.onPostResume();
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
hideFakeToolbarShadow();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void hideFakeToolbarShadow()
|
||||||
|
{
|
||||||
|
View view = findViewById(R.id.toolbarShadow);
|
||||||
|
if(view != null) view.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
28
app/src/main/res/drawable/toolbar_shadow.xml
Normal file
28
app/src/main/res/drawable/toolbar_shadow.xml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
|
||||||
|
~
|
||||||
|
~ This file is part of Loop Habit Tracker.
|
||||||
|
~
|
||||||
|
~ Loop Habit Tracker is free software: you can redistribute it and/or modify
|
||||||
|
~ it under the terms of the GNU General Public License as published by the
|
||||||
|
~ Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
~ option) any later version.
|
||||||
|
~
|
||||||
|
~ Loop Habit Tracker is distributed in the hope that it will be useful, but
|
||||||
|
~ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
~ more details.
|
||||||
|
~
|
||||||
|
~ You should have received a copy of the GNU General Public License along
|
||||||
|
~ with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
|
||||||
|
<gradient android:startColor="@android:color/transparent"
|
||||||
|
android:endColor="@color/black"
|
||||||
|
android:angle="90"/>
|
||||||
|
|
||||||
|
</shape>
|
||||||
@@ -191,4 +191,8 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/toolbarShadow"
|
||||||
|
style="@style/ToolbarShadow"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|||||||
@@ -17,10 +17,10 @@
|
|||||||
~ with this program. If not, see <http://www.gnu.org/licenses/>.
|
~ with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout android:id="@+id/container"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/container"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="org.isoron.uhabits.MainActivity"
|
tools:context="org.isoron.uhabits.MainActivity"
|
||||||
@@ -28,15 +28,19 @@
|
|||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<android.support.v7.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
app:popupTheme="?toolbarPopupTheme"
|
style="@style/Toolbar"
|
||||||
style="@style/Toolbar"/>
|
app:popupTheme="?toolbarPopupTheme"/>
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/fragment1"
|
android:id="@+id/fragment1"
|
||||||
android:name="org.isoron.uhabits.fragments.ListHabitsFragment"
|
android:name="org.isoron.uhabits.fragments.ListHabitsFragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:layout="@layout/list_habits_fragment"
|
android:layout_below="@id/toolbar"
|
||||||
android:layout_below="@id/toolbar"/>
|
tools:layout="@layout/list_habits_fragment"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/toolbarShadow"
|
||||||
|
style="@style/ToolbarShadow"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|||||||
@@ -39,4 +39,8 @@
|
|||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_below="@id/toolbar"/>
|
android:layout_below="@id/toolbar"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/toolbarShadow"
|
||||||
|
style="@style/ToolbarShadow"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|||||||
@@ -42,4 +42,8 @@
|
|||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_below="@id/toolbar"/>
|
android:layout_below="@id/toolbar"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/toolbarShadow"
|
||||||
|
style="@style/ToolbarShadow"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|||||||
@@ -222,4 +222,12 @@
|
|||||||
<style name="Preference.Category.Material">
|
<style name="Preference.Category.Material">
|
||||||
<item name="android:layout">@layout/preference_category_custom</item>
|
<item name="android:layout">@layout/preference_category_custom</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="ToolbarShadow">
|
||||||
|
<item name="android:layout_width">match_parent</item>
|
||||||
|
<item name="android:layout_height">3dp</item>
|
||||||
|
<item name="android:background">@drawable/toolbar_shadow</item>
|
||||||
|
<item name="android:alpha">0.25</item>
|
||||||
|
<item name="android:layout_below">@id/toolbar</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user