Improved MainActivity TabLayout by making tabMode=scrollable and adding an animation to the bitshares logo to visually show when the fragment it represents is selected.

This commit is contained in:
Severiano Jaramillo 2018-10-30 08:18:40 -06:00
parent 2ae5656c5c
commit bc9d671656
6 changed files with 32 additions and 22 deletions

View file

@ -43,13 +43,7 @@ class MainActivity : AppCompatActivity() {
tabLayout.setupWithViewPager(viewPager)
// Force first tab to show BTS icon
tabLayout.getTabAt(0)?.setIcon(R.drawable.bts_logo)
fab.setOnClickListener { view ->
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show()
}
tabLayout.getTabAt(0)?.setIcon(R.drawable.tab_home_selector)
}

View file

@ -0,0 +1,19 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="255dp"
android:height="255dp"
android:viewportWidth="255"
android:viewportHeight="255" >
<path
android:fillColor="#BBFEFEFE"
android:pathData="M128 0c70 0 127 57 127 127 0 71-57 128-127 128C57 255 0 198 0 127 0 57 57 0 128 0z"/>
<path
android:fillColor="#2A8336"
android:pathData="M178 73c-15-16-36-22-57-21l12 10c31 3 56 29 56 61 0 34-27 61-61 61s-62-27-62-61c0-13 4-25 11-35V73c-28 28-28 73 0 101l51 51 50-51c28-28 28-73 0-101z"/>
<path
android:fillColor="#009FE3"
android:pathData="M99 155c7 6 15 10 25 11v-27c-2 0-4-1-6-2l-19 18zm31-16v27c9-1 18-5 24-11l-19-18c-1 1-3 2-5 2zm-18-12c0 2 1 4 2 6l-19 19c-6-7-9-16-10-25h27zm57 0c-1 9-5 17-10 24l-19-19c1-1 1-3 2-5h27zm-57-6H85V86l29 29c-1 2-2 4-2 6zm56 0h-26c-1-2-1-4-3-6l19-19c6 7 10 16 10 25zm-14-29c-6-5-15-9-24-10v27c2 0 4 1 5 2l19-19zM85 77c7 8 30 30 34 34 1-1 3-2 5-2V65L85 30v47z"/>
</vector>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/bts_logo" android:state_selected="true" />
<item android:drawable="@drawable/bts_logo_unselected" />
</selector>

View file

@ -31,7 +31,9 @@
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
app:tabIndicatorHeight="0dp"
app:tabMode="scrollable"/>
</android.support.design.widget.AppBarLayout>
@ -41,12 +43,4 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@android:drawable/ic_dialog_email"/>
</android.support.design.widget.CoordinatorLayout>

View file

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorPrimary">#009FE3</color>
<color name="colorPrimaryDark">#0071b1</color>
<color name="colorAccent">#D81B60</color>
<color name="dark">#000</color>
</resources>

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>