まず第一に、私は CoordinatorLayouts に精通していません。いくつかのスクロール可能な CardViews を含むフラグメントがあります。下のシートを追加しようとしたときに、下のシートは coordinatorLayout の子である必要があるというエラーが表示されたので、coordinatorLayout を追加しました。もうスクロールできないようです
PS:ScrollView
aに置き換えてみましたがNestedScrollView
、うまくいきませんでした。XML タグの順序を編集しようとしましたが、何も解決しませんでした。まだスクロールできません。
Bottom Sheets
を使用せずに使用できる方法はありますCoordinatorLayout
か??
ScrollView を使用した 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>
NestedScrollView を使用した 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" >
<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>