WindowView


Source link: https://github.com/justasm/WindowView

WindowView

Window as in windowsill.

An Android ImageView that can be panned around by tilting your device, as if you were looking through a window.

Usage

Add it to your project using Gradle:

compile 'com.jmedeisis:windowview:0.2.0'

Use in place of an ImageView. Example XML layout file:

<com.jmedeisis.windowview.WindowView
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:src="@drawable/my_image" />

Please refer to the included sample application project for a complete example.

Configuration

You will typically want to configure the following attributes for the WindowView class:

  • wwv_max_pitch - maximum angle (in degrees) from origin for vertical device tilts. Default - 30°

  • wwv_max_roll - maximum angle (in degrees) from origin for horizontal device tilts. Default - 30°

  • wwv_vertical_origin - (in degrees) when device pitch equals this value, the image is centered vertically. Default - 0°

  • wwv_horizontal_origin - (in degrees) when device roll equals this value, the image is centered horizontally. Default - 0°

You may also want to configure more advanced attributes:

  • wwv_orientation_mode - Absolute or Relative (default). Specifies whether device tilt should be tracked with respect to Absolute world coordinates (i.e. pitch, roll w.r.t. ground plane) or with respect to the device orientation when WindowView is created, which WindowView refers to as the 'orientation origin'. If using the latter, i.e. Relative, you may use WindowView#resetOrientationOrigin(boolean) to set the orientation origin to that of the device when the method is called.

  • wwv_translate_mode - Constant or Proportional (default). Specifies how much the image is translated in response to device tilt. If Proportional, the image moves within the full range defined by max_pitch / max_roll, with the extremities of the image visible when device pitch / roll is at those angles. If Constant, the image moves a constant amount per unit of tilt which is defined by max_constant_translation, achieved when pitch / roll are at max_pitch / max_roll.

  • wwv_max_constant_translation - see above. Default - 150dp

  • wwv_sensor_sampling_period - the desired rate of sensor events. In microseconds or one of fast, normal (default) or slow. If using microsecond values, higher values result in slower sensor updates. Directly related to the rate at which WindowView updates in response to device tilt.

  • wwv_tilt_sensor_mode - Manual or Automatic (default). Specifies whether WindowView is responsible for when tilt motion tracking starts and stops. If Automatic, WindowView works out of the box and requires no extra configuration. If Manual, you must explicitly start and stop tilt motion tracking. You have two options:

    • Use WindowView#startTiltTracking() and WindowView#stopTiltTracking(), e.g. in your Activity's onResume() and onPause(), respectively.

    • Use WindowView#attachTiltTracking(TiltSensor) and WindowView#detachTiltTracking(TiltSensor). This approach is recommended when using multiple WindowViews in a single logical layout. The externally managed TiltSensor should be started and stopped using TiltSensor#startTracking(int) and TiltSensor#stopTracking() as appropriate.

Example configuration:

<com.jmedeisis.windowview.WindowView
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:src="@drawable/my_image"
  app:wwv_tilt_sensor_mode="Manual"
  app:wwv_orientation_mode="Relative"
  app:wwv_translate_mode="Constant"
  app:wwv_max_constant_translation="100dp"
  app:wwv_sensor_sampling_period="fast"
  app:wwv_max_pitch="15"
  app:wwv_max_roll="15"
  app:wwv_vertical_origin="0"
  app:wwv_horizontal_origin="0" />

Limitations

  • Only supports the CENTER_CROP scale type.
  • Works for API levels 9+.

Development

Pull requests are welcome and encouraged for bugfixes and features such as:

  • adaptive smoothing filters tuned for different sensor accuracy and rates
  • bi-directional image panning

License

WindowView is licensed under the terms of the MIT License.

Resources

An Android Layout Manager to create a gridview with cells of different sizes inspired by Flow Layout for iOS.

EditTextView suggests and fills up email domains.

A library for display a few images in one MultiImageView like avatar of group chat.

This library fits your GridView with its contents to a given size.

Displays a round or squared popup and attaches it to a View, like a callout. Uses the Builder pattern for maximum ease. The popup can automatically hide and can persist when the value is updated.

SlideUp is a small library that allows you to add sweet slide effect to any view.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes