Sha256: d7e1a7a23fe87a8423975e2cd1b71c2ed6a5ddbe1fca5e883fbc51845dc49327

Contents?: true

Size: 627 Bytes

Versions: 9

Compression:

Stored size: 627 Bytes

Contents

module UI
  class Label < UI::View
    include UI::Text

    def initialize
      super
      calculate_measure(true)
      self.text_alignment = :left
    end

    def height=(val)
      super
      calculate_measure(false)
    end

    def measure(width, height)
      dimension = [width, height]
      unless width.nan?
        layout = Android::Text::StaticLayout.new(proxy.text, proxy.paint, width, Android::Text::Layout::Alignment::ALIGN_NORMAL, 1, 0, true)
        dimension[1] = layout.height
      end
      dimension
    end

    def proxy
      @proxy ||= Android::Widget::TextView.new(UI.context)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
motion-flow-0.1.8 flow/ui/android/label.rb
motion-flow-0.1.7 flow/ui/android/label.rb
motion-flow-0.1.6 flow/ui/android/label.rb
motion-flow-0.1.5 flow/ui/android/label.rb
motion-flow-0.1.4 flow/ui/android/label.rb
motion-flow-0.1.3 flow/ui/android/label.rb
motion-flow-0.1.2 flow/ui/android/label.rb
motion-flow-0.1.1 flow/ui/android/label.rb
motion-flow-0.1 flow/ui/android/label.rb