Search in sources :

Example 51 with FloatingActionButton

use of android.support.design.widget.FloatingActionButton in project material-components-android by material-components.

the class TestUtilsMatchers method withFabContentHeight.

/** Returns a matcher that matches FloatingActionButtons with the specified content height */
public static Matcher withFabContentHeight(final int size) {
    return new BoundedMatcher<View, View>(View.class) {

        private String failedCheckDescription;

        @Override
        public void describeTo(final Description description) {
            description.appendText(failedCheckDescription);
        }

        @Override
        public boolean matchesSafely(final View view) {
            if (!(view instanceof FloatingActionButton)) {
                return false;
            }
            final FloatingActionButton fab = (FloatingActionButton) view;
            final Rect area = new Rect();
            fab.getContentRect(area);
            return area.height() == size;
        }
    };
}
Also used : Rect(android.graphics.Rect) Description(org.hamcrest.Description) FloatingActionButton(android.support.design.widget.FloatingActionButton) BoundedMatcher(android.support.test.espresso.matcher.BoundedMatcher) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 52 with FloatingActionButton

use of android.support.design.widget.FloatingActionButton in project material-components-android by material-components.

the class FloatingActionButtonActions method setBackgroundTintList.

public static ViewAction setBackgroundTintList(@ColorInt final ColorStateList tint) {
    return new ViewAction() {

        @Override
        public Matcher<View> getConstraints() {
            return isAssignableFrom(FloatingActionButton.class);
        }

        @Override
        public String getDescription() {
            return "Sets FloatingActionButton background tint";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            final FloatingActionButton fab = (FloatingActionButton) view;
            fab.setBackgroundTintList(tint);
            uiController.loopMainThreadUntilIdle();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) UiController(android.support.test.espresso.UiController) FloatingActionButton(android.support.design.widget.FloatingActionButton) View(android.view.View)

Example 53 with FloatingActionButton

use of android.support.design.widget.FloatingActionButton in project material-components-android by material-components.

the class FloatingActionButtonActions method setCompatElevation.

public static ViewAction setCompatElevation(final float size) {
    return new ViewAction() {

        @Override
        public Matcher<View> getConstraints() {
            return isAssignableFrom(FloatingActionButton.class);
        }

        @Override
        public String getDescription() {
            return "Sets FloatingActionButton elevation";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            final FloatingActionButton fab = (FloatingActionButton) view;
            fab.setCompatElevation(size);
            uiController.loopMainThreadUntilIdle();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) UiController(android.support.test.espresso.UiController) FloatingActionButton(android.support.design.widget.FloatingActionButton) View(android.view.View)

Example 54 with FloatingActionButton

use of android.support.design.widget.FloatingActionButton in project BeautifulRefreshLayout by android-cjj.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    final ActionBar ab = getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);
    ab.setTitle(null);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
        setupDrawerContent(navigationView);
    }
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    if (viewPager != null) {
        setupViewPager(viewPager);
    }
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Snackbar.make(view, "I'm CJJ", Snackbar.LENGTH_LONG).setAction("Action", null).show();
        }
    });
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
}
Also used : NavigationView(android.support.design.widget.NavigationView) TabLayout(android.support.design.widget.TabLayout) FloatingActionButton(android.support.design.widget.FloatingActionButton) ViewPager(android.support.v4.view.ViewPager) NavigationView(android.support.design.widget.NavigationView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 55 with FloatingActionButton

use of android.support.design.widget.FloatingActionButton in project ProguardSnips by PrashamTrivedi.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null).show();
        }
    });
}
Also used : FloatingActionButton(android.support.design.widget.FloatingActionButton) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

FloatingActionButton (android.support.design.widget.FloatingActionButton)79 View (android.view.View)56 Toolbar (android.support.v7.widget.Toolbar)29 TextView (android.widget.TextView)18 ImageView (android.widget.ImageView)15 Intent (android.content.Intent)12 RecyclerView (android.support.v7.widget.RecyclerView)11 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)9 ColorStateList (android.content.res.ColorStateList)8 Bundle (android.os.Bundle)8 NavigationView (android.support.design.widget.NavigationView)8 TabLayout (android.support.design.widget.TabLayout)8 ViewPager (android.support.v4.view.ViewPager)8 ActionBar (android.support.v7.app.ActionBar)7 UiController (android.support.test.espresso.UiController)6 ViewAction (android.support.test.espresso.ViewAction)6 AdapterView (android.widget.AdapterView)6 DrawerLayout (android.support.v4.widget.DrawerLayout)4 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)4 MenuItem (android.view.MenuItem)4