मैं एक एपबार लेआउट के साथ एक समन्वयक लेआउट का उपयोग करने की कोशिश कर रहा हूं जो "स्क्रॉलिंग व्यू" के रूप में एक टुकड़ा होस्ट करता है। टुकड़ा एक बटन को दबाए रखते हैं, तो जैसे एक recyclerView और एक नीचे गठबंधन लेआउट के होते हैं:खंडन के साथ समन्वयक लेआउट का उपयोग कैसे करें "स्क्रॉलिंग व्यू"
हालांकि, नीचे अनुभाग डिफ़ॉल्ट रूप से छुपा है:
और केवल दिखाता है स्क्रॉल करने के बाद।
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TestFragment fragment = (TestFragment) getFragmentManager().findFragmentByTag("Test");
if (fragment == null)
fragment = new TestFragment();
getFragmentManager().popBackStack();
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment, "Test");
fragmentTransaction.commit();
}
गतिविधि लेआउट:
मेरी गतिविधि वर्ग से<RelativeLayout 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">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="enterAlways|scroll"
app:tabGravity="fill"
app:tabMode="fixed"/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>
टुकड़ा लेआउट:
<RelativeLayout 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">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/bottomView"
android:scrollbars="vertical"
android:visibility="visible"/>
<RelativeLayout
android:id="@+id/bottomView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#d4285d"
app:layout_scrollFlags="enterAlways">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Do something..."
android:textSize="14sp"/>
</RelativeLayout>
</RelativeLayout>
अंत यहाँ लक्ष्य टुकड़ा नीचे बार हमेशा के लिए के लिए है स्क्रीन पर, और रीसाइक्लिंग दृश्य को ऐपबार को स्क्रॉल करना।
क्या यह संभव है?
धन्यवाद सब!
मैं एक ही समस्या है। मैं गतिविधि में 'नीचे लयआउट' डालकर (और फ्रैगमेंट नहीं) और कोऑर्डिनेटरआउट के बाहर आधे 'हल' किया। स्क्रॉल करते समय भी यह दिखाई देता है। हालांकि, मैं कभी-कभी इसे छिपाना चाहता हूं (स्क्रॉल करते समय नहीं, लेकिन जब मैं टूलबार बटन दबाता हूं), और उस स्थिति में स्क्रॉलिंग व्यू (रीसाइक्लर व्यू) पीछे की जगह को भर नहीं देता है, बल्कि यह 'खाली' रहता है (सफेद)। साथ ही, 'bottomView' स्क्रॉलिंग दृश्य के शीर्ष पर दिखाई देता है, भले ही यह कोऑर्डिनेटरलायआउट के बाहर और लाइनरलायआउट में इसके नीचे हो। मैं उलझन में हूं ... –
निक, मैं उस समय के लिए एक ही दृष्टिकोण ले रहा हूं, जहां नीचे लेआउट गतिविधि में डाल दिया गया है। मैंने इसे गतिविधि में फ़्रेमलेआउट जोड़कर एक सामान्य तरीके से संभाला, जिसे मैं खंड से एक्सेस करता हूं और वहां एक दृश्य जोड़ता हूं। यह गन्दा है, लेकिन मैं इसके चारों ओर नहीं मिल सका। मुझे कभी-कभी उस बार को छिपाने के साथ निपटने की ज़रूरत नहीं है (जब मैं टुकड़े स्विच करता हूं तो इसे पूरी तरह छिपाने के अलावा) तो मैं उस मुद्दे पर टिप्पणी नहीं कर सकता ... क्षमा करें। – Zach