我的 Scrollview 没有使用 LinearLayout android 滚动
My Scrollview is not scrolling with a LinearLayout android
我的 Scrollview 没有使用 LinearLayout 滚动 android
知道为什么吗?如果是这样,请回复,我最近开始 android 所以这可能真的很容易。但我搜索并无法修复它。帮助将不胜感激。
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:nestedScrollingEnabled="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:id="@+id/textView"
android:layout_gravity="center_horizontal"
android:paddingBottom="80dp"/>
<android.support.v7.widget.CardView
android:layout_width="375dp"
android:layout_height="300dp"
android:layout_gravity="center_horizontal"
app:cardCornerRadius="0dp"
app:cardElevation="3dp"
app:cardBackgroundColor="#161616">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/image"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>
查看布局,纵向可能没有足够的内容甚至需要滚动视图。我将其插入 Android Studio,但只能在横屏时滚动。
此外,作为一般规则,ScrollView
(您的 LinearLayout
)的 child 应该使用 wrap_content
而不是 match_parent
。
如果您希望 ScrollView
始终至少填满屏幕,您可以在 ScrollView
.
上使用 android:fillViewPort="true"
属性
您不能将可滚动视图 (cardView) 放在另一个可滚动视图 (LinearLayout) 中,因为这两个滚动不兼容。
如果您在 CardView 上方只有一个 TextView,我会删除 ScrollView,然后 CardView 将正常滚动。布局结构应该是:
<LinearLayout>
<TextView>
<Cardview>
...
</CardView>
</LinearLayout>
希望对您有所帮助。
我的 Scrollview 没有使用 LinearLayout 滚动 android
知道为什么吗?如果是这样,请回复,我最近开始 android 所以这可能真的很容易。但我搜索并无法修复它。帮助将不胜感激。
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:nestedScrollingEnabled="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:id="@+id/textView"
android:layout_gravity="center_horizontal"
android:paddingBottom="80dp"/>
<android.support.v7.widget.CardView
android:layout_width="375dp"
android:layout_height="300dp"
android:layout_gravity="center_horizontal"
app:cardCornerRadius="0dp"
app:cardElevation="3dp"
app:cardBackgroundColor="#161616">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/image"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>
查看布局,纵向可能没有足够的内容甚至需要滚动视图。我将其插入 Android Studio,但只能在横屏时滚动。
此外,作为一般规则,ScrollView
(您的 LinearLayout
)的 child 应该使用 wrap_content
而不是 match_parent
。
如果您希望 ScrollView
始终至少填满屏幕,您可以在 ScrollView
.
android:fillViewPort="true"
属性
您不能将可滚动视图 (cardView) 放在另一个可滚动视图 (LinearLayout) 中,因为这两个滚动不兼容。
如果您在 CardView 上方只有一个 TextView,我会删除 ScrollView,然后 CardView 将正常滚动。布局结构应该是:
<LinearLayout>
<TextView>
<Cardview>
...
</CardView>
</LinearLayout>
希望对您有所帮助。