public class

ReflectionLayout

extends FrameLayout
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ com.droidux.ui.widgets.layout.ReflectionLayout

Class Overview

ReflectionLayout is a layout container that will add a visual reflection to its child view. You can only place one child in it containing the entire contents to reflect; however, this child may itself be a layout manager with a complex hierarchy of objects, e.g. LinearLayout, RelativeLayout, etc.

Important notes:

  • You must set both the width and the height of the ReflectionLayout to WRAP_CONTENT, to create proper reflection effect.
  • Adding reflection requires memory resources. Don't overuse this widget to add reflection to very large views or too many views in one screen. For a simple bitmap reflection, use the ReflectionDrawable instead.

Note: ReflectionLayout depends on certain behaviour that is not compatible with the Android's hardware acceleration feature introduced since API-11. Therefore, if you're using this widget in your activity, you have to disable the hardware acceleration, at least on the <activity/> level, by setting the android:hardwareAccelerated attribute to false.

For more information on Android's hardware acceleration features, please follow this links:

Summary

XML Attributes
Attribute Name Related Method Description
duxlyt_floorGap setFloorGap(int) Specifies the distance from the bottom of the reflected view to the "floor". 
duxlyt_reflectged setReflected(boolean) If true, a reflection of the children of this layout will be drawn at the bottom. 
duxlyt_reflectionStrength setReflectionHeightFactor(float) Determines the height of the reflection. 
duxlyt_reflectionStrength setReflectionStrength(float) Determines the opacity of the reflection. 
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
ReflectionLayout(Context context)
ReflectionLayout(Context context, AttributeSet attrs)
ReflectionLayout(Context context, AttributeSet attrs, int defStyle)
Public Methods
Paint getEffectPaint()
Gets the Paint object used to apply effects when drawing this layout on canvas.
int getFloorGap()
Gets the distance between the bottom of the view to the 'floor' in a reflected view.
float getReflectionHeightFactor()
Gets the factor to calculate the reflection height.
float getReflectionStrength()
Gets the strength of the reflection in a reflected view.
int getReflectionTop()
Gets the top coordinate of the reflection bounds.
View getWrappedView()
Gets the view wrapped by this layout.
boolean isReflected()
Whether the view is reflected.
void setEffectPaint(Paint effectPaint)
The given Paint object will be used when drawing the layout to the canvas.
void setFloorGap(int floorGap)
Sets the distance between the bottom of the view to the 'floor' in a reflected view.
void setReflected(boolean reflected)
Sets whether to draw a reflection of the child view.
void setReflectionHeightFactor(float factor)
Sets the factor to calculate the reflection height.
void setReflectionStrength(float strength)
Sets the strength of the reflection in a reflected view.
[Expand]
Inherited Methods
From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource

XML Attributes

duxlyt_floorGap

Since: API Level

Specifies the distance from the bottom of the reflected view to the "floor". Its value should be a dimension (such as "5dip").

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), mm (millimeters).

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

Related Methods

duxlyt_reflectged

Since: API Level

If true, a reflection of the children of this layout will be drawn at the bottom. Default is true.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

Related Methods

duxlyt_reflectionStrength

Since: API Level

Determines the height of the reflection.

Must be a floating point value, such as "1.2".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

duxlyt_reflectionStrength

Since: API Level

Determines the opacity of the reflection.

Must be a floating point value, such as "1.2".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

Public Constructors

public ReflectionLayout (Context context)

Since: API Level 3.0

public ReflectionLayout (Context context, AttributeSet attrs)

Since: API Level 3.0

public ReflectionLayout (Context context, AttributeSet attrs, int defStyle)

Since: API Level 3.0

Public Methods

public Paint getEffectPaint ()

Since: API Level 3.0

Gets the Paint object used to apply effects when drawing this layout on canvas.

Returns

public int getFloorGap ()

Since: API Level 3.0

Gets the distance between the bottom of the view to the 'floor' in a reflected view.

Related XML Attributes
Returns
  • The floor gap.

public float getReflectionHeightFactor ()

Since: API Level 3.0

Gets the factor to calculate the reflection height. The reflection height is the factor multiply by the view's height.

Related XML Attributes
Returns
  • The reflection height factor.

public float getReflectionStrength ()

Since: API Level 3.0

Gets the strength of the reflection in a reflected view.

Related XML Attributes
Returns
  • The reflection strength

public int getReflectionTop ()

Since: API Level 3.0

Gets the top coordinate of the reflection bounds. This is the reflected layout bottom plus twice the floor gap.

Returns
  • Top (y-axis) coordinate.

public View getWrappedView ()

Since: API Level 3.0

Gets the view wrapped by this layout.

Returns

public boolean isReflected ()

Since: API Level 3.0

Whether the view is reflected.

Related XML Attributes
Returns
  • true if reflected, false otherwise.

public void setEffectPaint (Paint effectPaint)

Since: API Level 3.0

The given Paint object will be used when drawing the layout to the canvas. This is useful to apply some effects to the layout.

Parameters
effectPaint The effect Paint

public void setFloorGap (int floorGap)

Since: API Level 3.0

Sets the distance between the bottom of the view to the 'floor' in a reflected view.

Related XML Attributes
Parameters
floorGap The distance.

public void setReflected (boolean reflected)

Since: API Level 3.0

Sets whether to draw a reflection of the child view. Default is true.

Related XML Attributes
Parameters
reflected If true, draw reflection at the bottom of the child view.

public void setReflectionHeightFactor (float factor)

Since: API Level 3.0

Sets the factor to calculate the reflection height. The reflection height is the factor multiply by the view's height.

Related XML Attributes
Parameters
factor The reflection height factor.

public void setReflectionStrength (float strength)

Since: API Level 3.0

Sets the strength of the reflection in a reflected view.

Related XML Attributes
Parameters
strength The reflection strength