• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala AttributeSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中android.util.AttributeSet的典型用法代码示例。如果您正苦于以下问题:Scala AttributeSet类的具体用法?Scala AttributeSet怎么用?Scala AttributeSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了AttributeSet类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: FloatingActionMenuBehavior

//设置package包名称以及导入依赖的类
package com.github.shadowsocks.widget

import android.animation.ValueAnimator
import android.content.Context
import android.support.design.widget.CoordinatorLayout
import android.support.design.widget.CoordinatorLayout.Behavior
import android.support.design.widget.Snackbar.SnackbarLayout
import android.support.v4.view.animation.FastOutSlowInInterpolator
import android.util.AttributeSet
import android.view.View
import com.github.clans.fab.FloatingActionMenu

import scala.collection.JavaConverters._


class FloatingActionMenuBehavior(context: Context, attrs: AttributeSet)
  extends Behavior[FloatingActionMenu](context, attrs) {
  private var fabTranslationYAnimator: ValueAnimator = _
  private var fabTranslationY: Float = _

  override def layoutDependsOn(parent: CoordinatorLayout, child: FloatingActionMenu, dependency: View) =
    dependency.isInstanceOf[SnackbarLayout]

  override def onDependentViewChanged(parent: CoordinatorLayout, child: FloatingActionMenu, dependency: View) = {
    dependency match {
      case _: SnackbarLayout =>
        var targetTransY = parent.getDependencies(child).asScala
          .filter(view => view.isInstanceOf[SnackbarLayout] && parent.doViewsOverlap(child, view))
          .map(view => view.getTranslationY - view.getHeight).reduceOption(_ min _).getOrElse(0F)
        if (targetTransY > 0) targetTransY = 0
        if (fabTranslationY != targetTransY) {
          val currentTransY = child.getTranslationY
          if (fabTranslationYAnimator != null && fabTranslationYAnimator.isRunning) fabTranslationYAnimator.cancel
          if (child.isShown && Math.abs(currentTransY - targetTransY) > child.getHeight * 0.667F) {
            if (fabTranslationYAnimator == null) {
              fabTranslationYAnimator = new ValueAnimator
              fabTranslationYAnimator.setInterpolator(new FastOutSlowInInterpolator)
              fabTranslationYAnimator.addUpdateListener(animation =>
                child.setTranslationY(animation.getAnimatedValue.asInstanceOf[Float]))
            }
            fabTranslationYAnimator.setFloatValues(currentTransY, targetTransY)
            fabTranslationYAnimator.start
          } else child.setTranslationY(targetTransY)
          fabTranslationY = targetTransY
        }
    }
    false
  }

  override def onStartNestedScroll(parent: CoordinatorLayout, child: FloatingActionMenu, directTargetChild: View,
                                   target: View, nestedScrollAxes: Int) = true
  override def onNestedScroll(parent: CoordinatorLayout, child: FloatingActionMenu, target: View, dxConsumed: Int,
                              dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int) = {
    super.onNestedScroll(parent, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed)
    val dy = dyConsumed + dyUnconsumed
    if (child.isMenuButtonHidden) {
      if (dy < 0) child.showMenuButton(true)
    } else if (dy > 0) child.hideMenuButton(true)
  }
} 
开发者ID:mmmyc,项目名称:ssr-android,代码行数:61,代码来源:FloatingActionMenuBehavior.scala


示例2: EditTextPreference

//设置package包名称以及导入依赖的类
package be.mygod.preference

import android.content.Context
import android.support.v7.preference.{EditTextPreference => Parent}
import android.support.v7.widget.AppCompatEditText
import android.text.InputType
import android.util.AttributeSet


class EditTextPreference(context: Context, attrs: AttributeSet = null) extends Parent(context, attrs)
  with SummaryPreference {
  val editText = new AppCompatEditText(context, attrs)
  editText.setId(android.R.id.edit)

  override protected def getSummaryValue = {
    var text = getText
    if (text == null) text = ""
    val inputType = editText.getInputType
    if (inputType == (InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD) ||
      inputType == (InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD) ||
      inputType == (InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD))
      "\u2022" * text.length else text
  }

  override def setText(text: String) = {
    super.setText(text)
    notifyChanged
  }
} 
开发者ID:RoomArchitect,项目名称:test0000,代码行数:30,代码来源:EditTextPreference.scala


示例3: NumberPickerPreference

//设置package包名称以及导入依赖的类
package be.mygod.preference

import android.content.Context
import android.content.res.TypedArray
import android.support.v7.preference.DialogPreference
import android.util.AttributeSet
import android.view.ContextThemeWrapper
import android.widget.NumberPicker
import com.github.shadowsocks.R

class NumberPickerPreference(private val context: Context, attrs: AttributeSet = null)
  extends DialogPreference(context, attrs) with SummaryPreference {
  private[preference] val picker = new NumberPicker(new ContextThemeWrapper(context, R.style.NumberPickerStyle))
  private var value: Int = _

  {
    val a: TypedArray = context.obtainStyledAttributes(attrs, R.styleable.NumberPickerPreference)
    setMin(a.getInt(R.styleable.NumberPickerPreference_min, 0))
    setMax(a.getInt(R.styleable.NumberPickerPreference_max, Int.MaxValue - 1))
    a.recycle
  }

  def getValue = value
  def getMin = if (picker == null) 0 else picker.getMinValue
  def getMax = picker.getMaxValue
  def setValue(i: Int) {
    if (i == value) return
    picker.setValue(i)
    value = picker.getValue
    persistInt(value)
    notifyChanged
  }
  def setMin(value: Int) = picker.setMinValue(value)
  def setMax(value: Int) = picker.setMaxValue(value)

  override protected def onGetDefaultValue(a: TypedArray, index: Int): AnyRef =
    a.getInt(index, getMin).asInstanceOf[AnyRef]
  override protected def onSetInitialValue(restorePersistedValue: Boolean, defaultValue: Any) {
    val default = defaultValue.asInstanceOf[Int]
    setValue(if (restorePersistedValue) getPersistedInt(default) else default)
  }
  protected def getSummaryValue: AnyRef = getValue.asInstanceOf[AnyRef]
} 
开发者ID:RoomArchitect,项目名称:test0000,代码行数:44,代码来源:NumberPickerPreference.scala


示例4: ScrollViewEx

//设置package包名称以及导入依赖的类
package com.android.perrier1034.post_it_note.ui.views

import android.util.AttributeSet
import android.content.Context
import android.view.MotionEvent
import android.widget.ScrollView

class ScrollViewEx(ctx: Context, attrs: AttributeSet) extends ScrollView(ctx, attrs) {

  val DISTANCE = 20f
  var downX = 0f
  var downY = 0f

  def this(context: Context) = this(context, null)

  
  override def onInterceptTouchEvent(event: MotionEvent): Boolean = {

    // We have to call below to do scrolling properly.
    // So anyway call it and alloc the return value
    val b = super.onInterceptTouchEvent(event)

    // save touched position when "ACTION_DOWN" !
    if (event.getAction == MotionEvent.ACTION_DOWN) {
      downX = event.getX
      downY = event.getY
    }

    // calc distance
    if (event.getAction == MotionEvent.ACTION_UP) {
      return (Math.abs(event.getY - downY) > DISTANCE) || (Math.abs(event.getX - downX) > DISTANCE)
    }

    b
  }
} 
开发者ID:perrier1034,项目名称:Post-it-Note,代码行数:37,代码来源:ScrollViewEx.scala


示例5: HackyEditText

//设置package包名称以及导入依赖的类
package com.android.perrier1034.post_it_note.ui.views

import android.graphics.Canvas
import android.os.{Looper, Handler}
import android.support.v7.widget.AppCompatEditText
import android.util.AttributeSet
import android.content.Context
import android.view.inputmethod.InputMethodManager
import com.android.perrier1034.post_it_note.App

class HackyEditText(ctx: Context, attrs: AttributeSet) extends AppCompatEditText(ctx, attrs) {

  def this(ctx: Context) = this(ctx, null)

  var isTarget = false
  setWillNotDraw(false)

  override def onDraw(canvas: Canvas ) {
    super.onDraw(canvas)

    if (isTarget) {
      isTarget = false
      requestFocus()
      // setShowSoftInputOnFocus(true)

      if (isInputMethodTarget) {
        showKeyBoard()
      } else{
        // ugly hack but I have no choice.
        // this occur when CheckListAdapter.appendNewRow() called on creating new check-list-note
        new Thread(new Runnable() {
          override def run() = {
            new Handler(Looper.getMainLooper).postDelayed(new Runnable() {
              def run() = showKeyBoard()
            }, 50)
          }
        }).start()
      }
    }
  }

  def showKeyBoard() {
    val imm = getContext.getSystemService(Context.INPUT_METHOD_SERVICE).asInstanceOf[InputMethodManager]
    imm.showSoftInput(this, InputMethodManager.SHOW_FORCED)
  }

} 
开发者ID:perrier1034,项目名称:Post-it-Note,代码行数:48,代码来源:HackyEditText.scala


示例6: HackyViewPager

//设置package包名称以及导入依赖的类
package com.android.perrier1034.post_it_note.ui.views

import android.content.Context
import android.support.v4.view.ViewPager
import android.util.AttributeSet
import android.view.MotionEvent

class HackyViewPager(ctx: Context, attrs: AttributeSet) extends ViewPager(ctx, attrs) {

  def this(context: Context) = this(context, null)

  var isLocked = false

  override def onInterceptTouchEvent(ev: MotionEvent): Boolean = {
    if (!isLocked) {
      try {
        return super.onInterceptTouchEvent(ev)
      } catch {
        case e: IllegalArgumentException =>
          e.printStackTrace()
          return false
      }
    }
    false
  }

  override def onTouchEvent(event: MotionEvent): Boolean = {
    if (!isLocked) {
      return super.onTouchEvent(event)
    }
    false
  }

  def toggleLock() {
    isLocked = !isLocked
  }

  def setLocked(b: Boolean ) {
    isLocked = b
  }
} 
开发者ID:perrier1034,项目名称:Post-it-Note,代码行数:42,代码来源:HackyViewPager.scala


示例7: InterceptTouchEventListener

//设置package包名称以及导入依赖的类
package ru.wordmetrix.dreamcrammer
import android.widget.FrameLayout
import android.content.{Context}
import android.util.AttributeSet

import android.view.{View,GestureDetector,MotionEvent}
import android.support.v4.view.{MotionEventCompat,GestureDetectorCompat}

import ru.wordmetrix.dreamcrammer.db._
import ru.wordmetrix._

class InterceptTouchEventListener {
      def onInterceptTouchEvent(ev : MotionEvent) : Boolean = false
}

class OnInterceptTouchEvent(context : Context, attrs : AttributeSet, defStyle : Int) extends FrameLayout(context, attrs, defStyle) {
    log("OnItereceptTouchEvent attrs: %s", attrs)

    def this(context : Context, attrs : AttributeSet) = this(context, attrs, 0)

    def this(context : Context) = this(context, null, 0)

    var onInterceptTouchEventListener : Option[InterceptTouchEventListener] = None

    def setInterceptTouchEventListener(listener : InterceptTouchEventListener) = {
        onInterceptTouchEventListener = Some(listener)
    }

    override
    def onInterceptTouchEvent(ev : MotionEvent) = {
        log("Intercept %s",ev)
        onInterceptTouchEventListener match {
            case Some(x) => x.onInterceptTouchEvent(ev)
            case None => super.onInterceptTouchEvent(ev)
        }
    }
} 
开发者ID:electricmind,项目名称:dreamcrammer,代码行数:38,代码来源:onintercepttouchevent.scala


示例8: ScaledImageView

//设置package包名称以及导入依赖的类
package ru.wordmetrix.dreamcrammer
import android.widget.ImageView
import android.content.{Context}
import android.util.AttributeSet
import android.view.{MenuInflater,MenuItem, View}

import ru.wordmetrix.dreamcrammer.db._
import ru.wordmetrix._

class ScaledImageView(context : Context, attrs : AttributeSet, defStyle : Int) extends ImageView(context, attrs, defStyle) {
    log("ScaledImageMenu attrs: %s", attrs)

    def this(context : Context, attrs : AttributeSet) = this(context, attrs, 0)

    def this(context : Context) = this(context, null, 0)

    override
    def onMeasure (widthMeasureSpec : Int, heightMeasureSpec : Int) : Unit = {
        log("onMeasure", widthMeasureSpec, heightMeasureSpec)
        super.onMeasure(widthMeasureSpec, heightMeasureSpec)
    }
} 
开发者ID:electricmind,项目名称:dreamcrammer,代码行数:23,代码来源:scaledimageview.scala


示例9: TrypTextView

//设置package包名称以及导入依赖的类
package tryp
package droid
package view

import android.util.AttributeSet
import android.content.res.TypedArray
import android.content.res.ColorStateList

class TrypTextView(context: Context, attrs: AttributeSet, defStyle: Int)
extends android.widget.TextView(context, attrs, defStyle)
{
  def this(context: Context) = this(context, null, 0)
  def this(context: Context, attrs: AttributeSet) = this(context, attrs, 0)

  private var shadowColors: ColorStateList = null
  private var shadowDx: Float = 0
  private var shadowDy: Float = 0
  private var shadowRadius: Float = 0

  def updateShadowColor {
    if (shadowColors != null) {
      setShadowLayer(shadowRadius, shadowDx, shadowDy,
        shadowColors.getColorForState(getDrawableState, 0))
      invalidate
    }
  }

  override protected def drawableStateChanged {
    super.drawableStateChanged
    updateShadowColor
  }

  def setShadow(color: ColorStateList, radius: Double, x: Int = 0, y: Int = 0)
  {
    shadowColors = color
    shadowRadius = radius.toFloat
    shadowDx = x
    shadowDy = y
  }
} 
开发者ID:tek,项目名称:droid,代码行数:41,代码来源:text_view.scala



注:本文中的android.util.AttributeSet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala PreferenceManager类代码示例发布时间:2022-05-23
下一篇:
Scala ScalatraListener类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap