Move cardview on Snackbar - Co-ordinator layout

后端 未结 3 1430
自闭症患者
自闭症患者 2021-01-16 11:35

I have a custom textview in a cardview at the bottom of the screen and using snackbar to display error messages on logging in. Now when the snackbar shows, the sign up textv

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-16 11:59

    This is what I did in-case someone is looking out.

    activity_login.xml

    
    
    
    
    
        
    
            
    
                
    
                    
    
                        
                    
    
                    
    
                        
                    
    
                    
    
                        
                    
                
            
        
    
    
        
    
            
        
    
    

    CoordinatorBehavior.java

    public class CoordinatorBehavior extends CoordinatorLayout.Behavior {
    public CoordinatorBehavior(Context context, AttributeSet attrs) {
    }
    
    
    public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
        return dependency instanceof Snackbar.SnackbarLayout;
    }
    
    
    public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
        float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight());
        child.setTranslationY(translationY);
        return true;
    }
    

    }

提交回复
热议问题