Skip to content

Instantly share code, notes, and snippets.

@marianeum
marianeum / get-compose-root-view
Created May 27, 2022 14:51
Access compose root view in test
// Sometimes you may need access to the root view in a test when working with compose.
// This is particularly useful for screenshot tests with popups/dialog where the root view
// will be in a separate window, rather than the activity
// This snippet shows how this can be used
val view = composeTestRule.onNode(isDialog()).fetchRootView()
private fun SemanticsNodeInteraction.fetchRootView(): View {
val node = fetchSemanticsNode()
return (node.root as ViewRootForTest).view
@marianeum
marianeum / FloatingActionButton.java
Last active November 25, 2015 11:24
FloatingActionButton with custom ripple colours
package com.marianeum.fab;
import android.animation.AnimatorInflater;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Outline;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.RippleDrawable;
import android.util.AttributeSet;