Last active
August 14, 2017 09:44
-
-
Save vtthach/c3fe526b1032f776b6fdfc735c85df1d to your computer and use it in GitHub Desktop.
Android Design Support Library - Style, Thems, Colors and Typography
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app_themes.xml https://codelabs.developers.google.com/codelabs/material-design-style/img/5ffbda8697aa2b0f.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<!-- Base application theme. --> | |
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar"> | |
<!-- Customize your theme here. --> | |
<item name="colorPrimary">#3F51B5</item> | |
<!-- Light Indigo --> | |
<item name="colorPrimaryDark">#3949AB</item> | |
<!-- Dark Indigo --> | |
<item name="colorAccent">#00B0FF</item> | |
<!-- Blue --> | |
</style> | |
<style name="AppTheme" parent="AppTheme.Base"></style> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Percentage of scroll app bar | |
appBarLayout = (AppBarLayout) findViewById(R.id.appbar); | |
appBarLayout.addOnOffsetChangedListener(this); | |
@Override | |
public void onOffsetChanged(AppBarLayout appBarLayout, int offset) { | |
int maxScroll = appBarLayout.getTotalScrollRange(); | |
float percentage = (float) Math.abs(offset) / (float) maxScroll; | |
handleToolbarTitleVisibility(percentage); /// 0.0 -> 1.0 | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using NestedScrollView instead of ScrollView to support appbar_scrolling_view_behavior | |
<android.support.v4.widget.NestedScrollView | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
app:layout_behavior="@string/appbar_scrolling_view_behavior"/> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<android.support.design.widget.CoordinatorLayout> | |
<android.support.design.widget.AppBarLayout | |
android:layout_height="@dimen/app_bar_height" | |
android:fitsSystemWindows="true" | |
android:theme="@style/AppTheme.AppBarOverlay"> | |
<android.support.design.widget.CollapsingToolbarLayout | |
android:fitsSystemWindows="true" | |
app:contentScrim="?attr/colorPrimary" | |
app:titleEnabled="false" | |
app:layout_scrollFlags="scroll|snap|exitUntilCollapsed"> // Snap -> auto expand or collaps animation | |
<ImageView | |
app:layout_collapseMode="parallax" // Parallax -> create parallax effect when scroll | |
tools:background="@drawable/a" /> | |
<android.support.v7.widget.Toolbar | |
android:id="@+id/toolbar" | |
android:layout_width="match_parent" | |
android:layout_height="?attr/actionBarSize" | |
app:layout_collapseMode="pin" // pin -> keep the view Pin at where it is | |
app:popupTheme="@style/AppTheme.PopupOverlay"/> | |
</android.support.design.widget.CollapsingToolbarLayout> | |
</android.support.design.widget.CoordinatorLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Button with borderlessButtonStyle --> | |
<!-- Button with textColorr="?attr/colorPrimary --> | |
<Button | |
android:id="@+id/action_button" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_below="@+id/card_text" | |
style="?android:attr/borderlessButtonStyle" | |
android:textColor="?attr/colorPrimary" | |
android:text="Action" /> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment