mirror of
https://github.com/AllanWang/Frost-for-Facebook.git
synced 2024-11-08 20:12:39 +01:00
Fix/tab layout (#510)
* Test wrap content width * Compute badge icon dimensions * Reuse views * Remove unnecessary color set * Change image bound * Set min * Change dp * Snapshot * Hardcode dimensions * Add min width
This commit is contained in:
parent
f6499a8741
commit
f619522bd8
@ -210,9 +210,7 @@ class MainActivity : BaseActivity(),
|
||||
}
|
||||
adapter.pages.forEach {
|
||||
tabs.addTab(tabs.newTab()
|
||||
.setCustomView(BadgedIcon(this).apply {
|
||||
iicon = it.icon
|
||||
}))
|
||||
.setCustomView(BadgedIcon(this).apply { iicon = it.icon }))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import android.util.AttributeSet
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import ca.allanwang.kau.utils.*
|
||||
import com.mikepenz.iconics.IconicsDrawable
|
||||
import com.mikepenz.iconics.typeface.IIcon
|
||||
import com.pitchedapps.frost.R
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
@ -31,12 +32,10 @@ class BadgedIcon @JvmOverloads constructor(
|
||||
badgeTextView.setTextColor(Prefs.mainActivityLayout.iconColor())
|
||||
}
|
||||
|
||||
|
||||
var iicon: IIcon? = null
|
||||
get() = field
|
||||
set(value) {
|
||||
field = value
|
||||
badgeImage.setImageDrawable(value?.toDrawable(context, color = Prefs.mainActivityLayout.iconColor()))
|
||||
badgeImage.setImageDrawable(value?.toDrawable(context, sizeDp = 20, color = Prefs.mainActivityLayout.iconColor()))
|
||||
}
|
||||
|
||||
fun setAllAlpha(alpha: Float) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main_content"
|
||||
android:layout_width="match_parent"
|
||||
@ -14,36 +13,14 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay">
|
||||
<include layout="@layout/view_main_toolbar" />
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:tabIndicatorHeight="0dp" />
|
||||
<include layout="@layout/view_main_tab_layout" />
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<com.pitchedapps.frost.views.FrostViewPager
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
<include layout="@layout/view_main_viewpager" />
|
||||
|
||||
<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/kau_fab_margin"
|
||||
android:visibility="gone" />
|
||||
<include layout="@layout/view_main_fab" />
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@ -21,40 +19,17 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay">
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
<include layout="@layout/view_main_toolbar" />
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<com.pitchedapps.frost.views.FrostViewPager
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
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/kau_fab_margin"
|
||||
android:visibility="gone" />
|
||||
<include layout="@layout/view_main_viewpager" />
|
||||
|
||||
<include layout="@layout/view_main_fab" />
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
app:tabIndicatorHeight="0dp" />
|
||||
<include layout="@layout/view_main_tab_layout" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -3,11 +3,12 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp">
|
||||
android:layout_height="@dimen/tab_bar_height"
|
||||
android:minWidth="@dimen/tab_bar_height">
|
||||
|
||||
<android.support.constraint.Guideline
|
||||
android:id="@+id/g_v_c"
|
||||
android:layout_width="1dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintGuide_percent="0.5"
|
||||
@ -17,7 +18,7 @@
|
||||
<android.support.constraint.Guideline
|
||||
android:id="@+id/g_h_c"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="1dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintGuide_percent="0.5"
|
||||
tools:layout_editor_absoluteX="0dp"
|
||||
|
8
app/src/main/res/layout/view_main_fab.xml
Normal file
8
app/src/main/res/layout/view_main_fab.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.FloatingActionButton xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:layout_margin="@dimen/kau_fab_margin"
|
||||
android:visibility="gone" />
|
10
app/src/main/res/layout/view_main_tab_layout.xml
Normal file
10
app/src/main/res/layout/view_main_tab_layout.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.TabLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/tabs"
|
||||
style="@style/Widget.Design.TabLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/tab_bar_height"
|
||||
app:tabGravity="fill"
|
||||
app:tabIndicatorHeight="0dp"
|
||||
app:tabMode="fixed" />
|
8
app/src/main/res/layout/view_main_toolbar.xml
Normal file
8
app/src/main/res/layout/view_main_toolbar.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
7
app/src/main/res/layout/view_main_viewpager.xml
Normal file
7
app/src/main/res/layout/view_main_viewpager.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.pitchedapps.frost.views.FrostViewPager xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
@ -5,5 +5,6 @@
|
||||
|
||||
<dimen name="context_menu_height">60dp</dimen>
|
||||
|
||||
<dimen name="tab_bar_height">50dp</dimen>
|
||||
<dimen name="intro_bar_height">64dp</dimen>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user