本文整理汇总了Scala中android.support.v7.widget.Toolbar类的典型用法代码示例。如果您正苦于以下问题:Scala Toolbar类的具体用法?Scala Toolbar怎么用?Scala Toolbar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Toolbar类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: BaseActivity
//设置package包名称以及导入依赖的类
package com.android.perrier1034.post_it_note.ui
import android.graphics.drawable.ColorDrawable
import android.os.{Build, Bundle}
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.Toolbar
import android.view.{View, ViewGroup, WindowManager}
import com.android.perrier1034.post_it_note.{Constants, R}
abstract class BaseActivity extends AppCompatActivity {
lazy val mToolbar = findViewById(R.id.toolbar).asInstanceOf[Toolbar]
lazy val mStatusBar = findViewById(R.id.status_bar)
protected def contentsResId: Int
protected def init()
override final def onCreate(savedInstanceState: Bundle) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_base)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
getWindow.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
}
val container = findViewById(R.id.container).asInstanceOf[ViewGroup]
initToolbar(container)
View.inflate(this, contentsResId, container)
init()
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
getWindow.setBackgroundDrawable(new ColorDrawable(Constants.STATUS_BAR_COLOR_BASE))
}
def initToolbar(container: ViewGroup) = {
setSupportActionBar(mToolbar)
mToolbar.setBackgroundColor(Constants.TOOL_BAR_COLOR_BASE)
}
def getToolbar: Toolbar = mToolbar
def setStatusBarColorByPosition(_pos: Int) {
val pos: Int = if (_pos >= 0) _pos else 14
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow.setStatusBarColor(Constants.PAGER_COLOR_MAPPING(pos)(3))
}
else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
mStatusBar.setBackgroundColor(Constants.PAGER_COLOR_MAPPING(pos)(0))
}
}
def setActionModeStatusBarColorLOLLIPOP() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
getWindow.setStatusBarColor(Constants.STATUS_BAR_COLOR_ACTION_MODE)
}
}
示例2: colorizeToolbar
//设置package包名称以及导入依赖的类
package app.bitrader.helpers.activity
import android.graphics.{PorterDuff, PorterDuffColorFilter}
import android.support.v7.widget.Toolbar
import android.view.View
import android.widget.{ActionMenuView, ImageButton, TextView}
import app.bitrader.helpers.AdditionalTweaks
import macroid.{ContextWrapper, Transformer}
import macroid._
trait ActivityStyles extends AdditionalTweaks{
def colorizeToolbar(toolbar: Toolbar, color: Int) = {
val filter: PorterDuffColorFilter = new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY)
toolbar.setTitleTextColor(color)
toolbar.setSubtitleTextColor(color)
println("applyThemeColors " + toolbar.getTitle)
for (i <- 0 to toolbar.getChildCount) {
val view: View = toolbar.getChildAt(i)
println("apply styles view " + view)
view match {
case v: ImageButton => v.getDrawable.setColorFilter(filter)
case t: TextView => t.setTextColor(color)
case am: ActionMenuView =>
case _ =>
}
}
}
def fitsAll(implicit c: ContextWrapper): Transformer = {
Transformer {
case a => a <~ fits
}
}
}