Skip to content

Most visited

Recently visited

navigation

WearableFrameLayout

public class WearableFrameLayout
extends ViewGroup

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.support.wearable.view.WearableFrameLayout


WearableFrameLayout works exactly like FrameLayout, except it can have overrides for a round screen. Besides using normal FrameLayout.LayoutParams attributes in your layout, you can also use *Round overrides, that will be applied instead if the device has a round screen. For example:


 <android.support.wearable.view.WearableFrameLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     >

     <ImageView
         android:id="@+id/preview"
         android:layout_height="@dimen/watch_face_entry_preview_width"
         android:layout_width="@dimen/watch_face_entry_preview_width"
         android:layout_marginTop="@dimen/watch_face_entry_preview_margin_top"
         app:layout_heightRound="@dimen/watch_face_entry_circular_preview_size"
         app:layout_widthRound="@dimen/watch_face_entry_circular_preview_size"
         app:layout_marginTopRound="@dimen/watch_face_entry_circular_preview_margin_top"
         app:layout_gravityRound="center_horizontal"
         />

 </android.support.wearable.view.WearableFrameLayout>
 
There might be subtle differences in behavior between FrameLayout and WearableFrameLayout, because this class doesn't have access to all hidden APIs that FrameLayout does. One example is setForeground, where Drawable parameter won't receive setLayoutDirection call.

Summary

Nested classes

class WearableFrameLayout.LayoutParams

Per-child layout information for layouts on wearable devices. 

Inherited constants

From class android.view.ViewGroup
From class android.view.View

Inherited fields

From class android.view.ViewGroup
From class android.view.View

Public constructors

WearableFrameLayout(Context context)
WearableFrameLayout(Context context, AttributeSet attrs)
WearableFrameLayout(Context context, AttributeSet attrs, int defStyleAttr)
WearableFrameLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Public methods

void draw(Canvas canvas)

void drawableHotspotChanged(float x, float y)
WearableFrameLayout.LayoutParams generateLayoutParams(AttributeSet attrs)

Drawable getForeground()

Returns the drawable used as the foreground of this FrameLayout.

int getForegroundGravity()

Describes how the foreground is positioned.

ColorStateList getForegroundTintList()
PorterDuff.Mode getForegroundTintMode()
boolean getMeasureAllChildren()

Determines whether all children, or just those in the VISIBLE or INVISIBLE state, are considered when measuring.

void jumpDrawablesToCurrentState()
WindowInsets onApplyWindowInsets(WindowInsets insets)
void onInitializeAccessibilityEvent(AccessibilityEvent event)
void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)
void setForeground(Drawable d)

Supply a Drawable that is to be rendered on top of all of the child views in the frame layout.

void setForegroundGravity(int foregroundGravity)

Describes how the foreground is positioned.

void setForegroundInPadding(boolean value)

Sets whether foreground should be in padding.

void setForegroundTintList(ColorStateList tint)

Applies a tint to the foreground drawable.

void setForegroundTintMode(PorterDuff.Mode tintMode)

Specifies the blending mode used to apply the tint specified by setForegroundTintList(ColorStateList)} to the foreground drawable.

void setMeasureAllChildren(boolean measureAll)

Sets whether to consider all children, or just those in the VISIBLE or INVISIBLE state, when measuring.

void setVisibility(int visibility)
boolean shouldDelayChildPressedState()

Protected methods

boolean checkLayoutParams(ViewGroup.LayoutParams p)

void drawableStateChanged()

WearableFrameLayout.LayoutParams generateDefaultLayoutParams()

Returns a set of layout parameters with a width of MATCH_PARENT, and a height of MATCH_PARENT.

ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed)
void onAttachedToWindow()
void onLayout(boolean changed, int left, int top, int right, int bottom)

void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

void onSizeChanged(int w, int h, int oldw, int oldh)

boolean verifyDrawable(Drawable who)

Inherited methods

From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.view.ViewParent
From interface android.view.ViewManager
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

Public constructors

WearableFrameLayout

WearableFrameLayout (Context context)

Parameters
context Context

WearableFrameLayout

WearableFrameLayout (Context context,
                AttributeSet attrs)

Parameters
context Context
attrs AttributeSet

WearableFrameLayout

WearableFrameLayout (Context context,
                AttributeSet attrs,
                int defStyleAttr)

Parameters
context Context
attrs AttributeSet
defStyleAttr int

WearableFrameLayout

WearableFrameLayout (Context context,
                AttributeSet attrs,
                int defStyleAttr,
                int defStyleRes)

Parameters
context Context
attrs AttributeSet
defStyleAttr int
defStyleRes int

Public methods

draw

void draw (Canvas canvas)

Parameters
canvas Canvas

drawableHotspotChanged

void drawableHotspotChanged (float x,
                float y)

Parameters
x float
y float

generateLayoutParams

WearableFrameLayout.LayoutParams generateLayoutParams (AttributeSet attrs)

Parameters
attrs AttributeSet
Returns
WearableFrameLayout.LayoutParams

getForeground

Drawable getForeground ()

Returns the drawable used as the foreground of this FrameLayout. The foreground drawable, if non-null, is always drawn on top of the children.

Returns
Drawable A Drawable or null if no foreground was set.

getForegroundGravity

int getForegroundGravity ()

Describes how the foreground is positioned.

Returns
int foreground gravity.

See also:

getForegroundTintList

ColorStateList getForegroundTintList ()

Returns
ColorStateList the tint applied to the foreground drawable

See also:

getForegroundTintMode

PorterDuff.Mode getForegroundTintMode ()

Returns
PorterDuff.Mode the blending mode used to apply the tint to the foreground drawable

See also:

getMeasureAllChildren

boolean getMeasureAllChildren ()

Determines whether all children, or just those in the VISIBLE or INVISIBLE state, are considered when measuring.

Returns
boolean Whether all children are considered when measuring.

jumpDrawablesToCurrentState

void jumpDrawablesToCurrentState ()

onApplyWindowInsets

WindowInsets onApplyWindowInsets (WindowInsets insets)

Parameters
insets WindowInsets
Returns
WindowInsets

onInitializeAccessibilityEvent

void onInitializeAccessibilityEvent (AccessibilityEvent event)

Parameters
event AccessibilityEvent

onInitializeAccessibilityNodeInfo

void onInitializeAccessibilityNodeInfo (AccessibilityNodeInfo info)

Parameters
info AccessibilityNodeInfo

setForeground

void setForeground (Drawable d)

Supply a Drawable that is to be rendered on top of all of the child views in the frame layout. Any padding in the Drawable will be taken into account by ensuring that the children are inset to be placed inside of the padding area.

Parameters
d Drawable: The Drawable to be drawn on top of the children.

setForegroundGravity

void setForegroundGravity (int foregroundGravity)

Describes how the foreground is positioned. Defaults to START and TOP.

Parameters
foregroundGravity int: See Gravity

See also:

setForegroundInPadding

void setForegroundInPadding (boolean value)

Sets whether foreground should be in padding. True by default.

Parameters
value boolean

setForegroundTintList

void setForegroundTintList (ColorStateList tint)

Applies a tint to the foreground drawable. Does not modify the current tint mode, which is SRC_IN by default.

Subsequent calls to setForeground(Drawable) will automatically mutate the drawable and apply the specified tint and tint mode using setTintList(ColorStateList).

Parameters
tint ColorStateList: the tint to apply, may be null to clear tint

See also:

setForegroundTintMode

void setForegroundTintMode (PorterDuff.Mode tintMode)

Specifies the blending mode used to apply the tint specified by setForegroundTintList(ColorStateList)} to the foreground drawable. The default mode is SRC_IN.

Parameters
tintMode PorterDuff.Mode: the blending mode used to apply the tint, may be null to clear tint

See also:

setMeasureAllChildren

void setMeasureAllChildren (boolean measureAll)

Sets whether to consider all children, or just those in the VISIBLE or INVISIBLE state, when measuring. Defaults to false.

Parameters
measureAll boolean: true to consider children marked GONE, false otherwise. Default value is false.

setVisibility

void setVisibility (int visibility)

Parameters
visibility int

shouldDelayChildPressedState

boolean shouldDelayChildPressedState ()

Returns
boolean

Protected methods

checkLayoutParams

boolean checkLayoutParams (ViewGroup.LayoutParams p)

Parameters
p ViewGroup.LayoutParams
Returns
boolean

drawableStateChanged

void drawableStateChanged ()

generateDefaultLayoutParams

WearableFrameLayout.LayoutParams generateDefaultLayoutParams ()

Returns a set of layout parameters with a width of MATCH_PARENT, and a height of MATCH_PARENT.

Returns
WearableFrameLayout.LayoutParams

generateLayoutParams

ViewGroup.LayoutParams generateLayoutParams (ViewGroup.LayoutParams p)

Parameters
p ViewGroup.LayoutParams
Returns
ViewGroup.LayoutParams

measureChildWithMargins

void measureChildWithMargins (View child,
                int parentWidthMeasureSpec,
                int widthUsed,
                int parentHeightMeasureSpec,
                int heightUsed)

Parameters
child View
parentWidthMeasureSpec int
widthUsed int
parentHeightMeasureSpec int
heightUsed int

onAttachedToWindow

void onAttachedToWindow ()

onLayout

void onLayout (boolean changed,
                int left,
                int top,
                int right,
                int bottom)

Parameters
changed boolean
left int
top int
right int
bottom int

onMeasure

void onMeasure (int widthMeasureSpec,
                int heightMeasureSpec)

Parameters
widthMeasureSpec int
heightMeasureSpec int

onSizeChanged

void onSizeChanged (int w,
                int h,
                int oldw,
                int oldh)

Parameters
w int
h int
oldw int
oldh int

verifyDrawable

boolean verifyDrawable (Drawable who)

Parameters
who Drawable
Returns
boolean
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.