मेरे पास XML के साथ एक गतिविधि है।दो कोऑर्डिनेटर के स्क्रॉल को सिंक करने के लिए कैसे करें + AppBarLayout
कुछ की तरह:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<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.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/primary"
android:theme="@style/ToolbarStyle"
android:gravity="center_vertical"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways|snap"
style="@style/bold" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/TabLayoutStyle"
android:animateLayoutChanges="true"
app:tabGravity="fill"
app:tabMode="fixed"
app:tabTextAppearance="@style/TabStyle"/>
</android.support.design.widget.AppBarLayout>
<com.wedmegood.planner.view.XViewPager
android:id="@+id/main_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
...
</android.support.v4.widget.DrawerLayout>
ViewPager
का एक Fragment
एक CoordinatorLayout
और AppBarLayout
+ CollapsingToolbarLayout
है।
Fragment
की एक्सएमएल:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/primaryDark"
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:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapse_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/my_wedding_banner_height"
android:minHeight="48dp"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<RelativeLayout
android:id="@+id/banner"
android:layout_width="match_parent"
android:layout_marginTop="0dp"
android:layout_height="match_parent"
app:layout_collapseMode="none">
</RelativeLayout>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_gravity="bottom"
android:animateLayoutChanges="true"
app:tabMode="fixed"
app:tabGravity="fill"
app:tabTextColor="@color/primary"
app:tabSelectedTextColor="@color/primary"
app:tabIndicatorColor="@color/accent"
app:tabIndicatorHeight="4dp"
app:tabTextAppearance="@style/TabStyle"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<com.wedmegood.planner.view.XViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
टुकड़ा एक बैनर, RelativeLayout है। मैं इन दो AppBarLayouts
की स्क्रॉल को सिंक करना चाहता हूं ताकि बाहरी ऐपबार पहले या बाद में गिर जाए (इससे पहले कि यह पहले या बाद में होता है) अंदरूनी ऐपबार गिरने से कोई फर्क नहीं पड़ता? मैंने अपने ऑफसेट परिवर्तन श्रोता के आधार पर 2 ऐपबार्स के स्क्रॉल झंडे को सेट और अनसेट करने का प्रयास किया, यह थोड़े काम करता है लेकिन एक चिकनी स्क्रॉल प्रभाव नहीं देता है। जब तक बैनर ठीक काम करता है तब तक मैं खंड के एक्सएमएल को पूरी तरह से बदल सकता हूं।
साथ ही, क्या CollapsingToolbarLayout को ध्वस्त/विस्तारित करते समय स्टाइल/कॉल TabLayout के setTabTextColors को बदलने का कोई तरीका है?
आपका मतलब है, आप उन्हें एक में विलय करना चाहते हैं? यह भी: ** स्टाइल/कॉल को बदलने का कोई तरीका है TabLayout के setTabTextColors जब CollapsingToolbarLayout ध्वस्त हो जाता है/विस्तार करता है ** इसे किसी अन्य विषय को खोलने या ASK प्रश्न का उपयोग करने के लिए बेहतर पूछता है। – Mohsen