यह ऊपर की ओर "अगला" बटन पुश करने के लिए जब snackbar
दिख रहा है मेरा प्रयास है। ऐसा प्रतीत होता है जैसे textview
को RelativeLayout
पर धक्का दिया गया था और फिर snackbar
गायब होने पर फिर से दिखाई देता है। इसके बजाय, मैं जो चाहता हूं वह textview
धक्का देने के लिए है (इसलिए यह snackbar
से ऊपर है) और फिर snackbar
गायब होने पर वापस आ गया। मैं भी इस प्रदर्शन करने के लिए एक छोटा सा GitHub रेपो बनाया है:स्नैकबार प्रदर्शित होने पर मैं मौजूदा दृश्य को कैसे दबा सकता हूं?</p> <p><img src="https://i.stack.imgur.com/Map0v.gif" height="400"></p> <p>आप देख सकते हैं, यह योजना के अनुसार काम नहीं करता:
https://github.com/Winghin2517/TestFabMotion
यहाँ CoordinatorLayout.Behavior
मैं "अगले" के लिए उपयोग अपने आप को छुपा रहा है। जब snackbar
प्रकट होता है जब इसे पुश होने पर व्यवहार फैब व्यवहार से लिया जाता है:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinatorlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Click Here!"
android:textAllCaps="true"
android:textStyle="bold"
android:background="@color/colorAccent"
android:id="@+id/click_here"
android:textSize="22sp"
android:layout_marginBottom="12dp"
android:gravity="center_horizontal"
android:paddingTop="24dp"
android:paddingLeft="24dp"
android:paddingRight="24dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/click_here"
android:layout_centerHorizontal="true"
android:src="@mipmap/ic_launcher"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/next"
android:text="Next"
android:layout_alignParentBottom="true"
android:background="@color/colorAccent"
android:clickable="true"
android:gravity="center_horizontal"
android:padding="16dp"
android:textAllCaps="true"
android:textStyle="bold"
app:layout_behavior="fabmotiontest.com.fabtest.FloatingActionButtonBehavior" />
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
मैं भी इस एक्सएमएल का उपयोग कर की कोशिश की है:
public class FloatingActionButtonBehavior extends CoordinatorLayout.Behavior<TextView> {
public FloatingActionButtonBehavior(Context context, AttributeSet attrs) {
}
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, TextView child, View dependency) {
return dependency instanceof Snackbar.SnackbarLayout;
}
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, TextView child, View dependency) {
float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight());
child.setTranslationY(translationY);
return true;
}
}
मैं इस इस एक्सएमएल का उपयोग कर की कोशिश की है
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Click Here!"
android:textAllCaps="true"
android:textStyle="bold"
android:background="@color/colorAccent"
android:id="@+id/click_here"
android:textSize="22sp"
android:layout_marginBottom="12dp"
android:gravity="center_horizontal"
android:paddingTop="24dp"
android:paddingLeft="24dp"
android:paddingRight="24dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/click_here"
android:layout_centerHorizontal="true"
android:src="@mipmap/ic_launcher"/>
</RelativeLayout>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinatorlayout"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/next"
android:text="Next"
android:background="@color/colorAccent"
android:clickable="true"
android:gravity="center_horizontal"
android:padding="16dp"
android:textAllCaps="true"
android:textStyle="bold"
app:layout_behavior="fabmotiontest.com.fabtest.FloatingActionButtonBehavior" />
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
यह काम नहीं करता प्रतीत होता है। क्या कोई जानता है कि मैं इसे कैसे काम कर सकता हूं?
हाय, साइमन, मेरे मामले में मैं लपेटें तल पर यह दिखाने के लिए cardView करने के लिए सामग्री सेट करने के लिए, लेकिन जब स्नैक बार cardview ऊपर जाता है, लेकिन यह चादर सामग्री की वजह से कटौती हो जाता है, लेकिन यह माता पिता के शीर्ष पर कहते हैं मैच के लिए स्थापित करने से पता चलता ऑल व्यू। कृपया सुझाव दें! आर एल -> Cordinator -> CardView (फैब संपत्ति के साथ) -> Relativelayout (दो छवियों के साथ) –