首先我不熟悉CoordinatorLayouts,我有一個包含多個可滾動CardViews的片段,當我嘗試添加底部表單時,我得到了底部表單必須是一個coordinatorLayout錯誤,所以我加了一個coordinatorLayout,現在我似乎無法能再滾動Android - 協調器佈局中的滾動和底部表格
PS:我試着用NestedScrollView
更換ScrollView
,它沒有工作,我甚至嘗試編輯XML標籤順序但沒有解決它,我仍然無法滾動
有沒有辦法可以使用Bottom Sheets
而不必使用CoordinatorLayout
?
這裏的XML佈局片段與滾動型:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".ThreeFragment" >
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/MainScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="false">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical"
android:padding="10dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
style="@style/MyCardViewStyleTitle"
android:id="@+id/view">
<TextView
android:text="I- Pure Vowels"
android:textStyle="normal"
android:background="@color/colorPrimaryDark"
android:textSize="20dp"
android:textColor="@color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_marginBottom="1dp"
android:layout_height="wrap_content"
style="@style/MyCardViewStyleContent"
android:id="@+id/textView10"
android:layout_below="@+id/view"
android:layout_alignParentStart="true">
<TextView
android:text="Pronouncing : á"
android:textStyle="bold|italic"
android:textSize="17dp"
android:textColor="@color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:text="\n\nas in English father\nE.g. ár ‘year’"
android:textStyle="normal"
android:textSize="40px"
android:textColor="@color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</android.support.v7.widget.CardView>
<!-- more cardviews -->
</LinearLayout>
</ScrollView>
<!-- Bottom Sheet Layout-->
<include layout="@layout/learn_more_sheet" />
</android.support.design.widget.CoordinatorLayout>
這裏的XML佈局片段與NestedScrollView:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".ThreeFragment" >
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/MainScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="false">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical"
android:padding="10dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
style="@style/MyCardViewStyleTitle"
android:id="@+id/view">
<TextView
android:text="I- Pure Vowels"
android:textStyle="normal"
android:background="@color/colorPrimaryDark"
android:textSize="20dp"
android:textColor="@color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_marginBottom="1dp"
android:layout_height="wrap_content"
style="@style/MyCardViewStyleContent"
android:id="@+id/textView10"
android:layout_below="@+id/view"
android:layout_alignParentStart="true">
<TextView
android:text="Pronouncing : á"
android:textStyle="bold|italic"
android:textSize="17dp"
android:textColor="@color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:text="\n\nas in English father\nE.g. ár ‘year’"
android:textStyle="normal"
android:textSize="40px"
android:textColor="@color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</android.support.v7.widget.CardView>
<!-- more cardviews -->
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<!-- Bottom Sheet Layout-->
<include layout="@layout/learn_more_sheet" />
</android.support.design.widget.CoordinatorLayout>
主要活動XML佈局
<android.support.design.widget.CoordinatorLayout
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"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.incorp.anisvikernes.englishtonorse.MainActivity">
>
<android.support.design.widget.AppBarLayout
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="160px"
app:tabMode="fixed"
app:tabGravity="fill"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
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>
1.更改android.support.v4.widget.NestedScrollViewScrollView到android.support.v4.widget.NestedScrollView。 2.你想讓每張卡片能夠單獨滾動,還是希望整個視圖可以滾動? – amitairos
爲你的第一步,請原諒它已經是'android.support.v4.widget.NestedScrollView',我希望整個視圖滾動 –
@Sígvardr你發佈的代碼有一個錯字錯誤:android.support.v4.widget .NestedScrollViewScrollView – amitairos