我的滚动视图不滚动LinearLayout android
我的滚动视图不滚动LinearLayout android我的滚动视图不滚动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
)的孩子应该使用wrap_content
而不是match_parent
。
如果您希望您的ScrollView
始终至少填满屏幕,则可以使用ScrollView
上的android:fillViewPort="true"
属性。
是的,我打算在未来添加更多的内容。 –
在布局中创建2个更多相同的'CardView'并查看它是否随后滚动。 –
谢谢,它的工作!我添加了更多cardview并滚动。 –
因为两个滚动条不兼容,所以不能在另一个可滚动视图(LinearLayout)中放置可滚动视图(cardView)。
如果你只有一个TextView上方CardView,我会删除ScrollView,然后CardView将正常滚动。布局结构应该是:
<LinearLayout>
<TextView>
<Cardview>
...
</CardView>
</LinearLayout>
希望它有帮助。
CardView可能会盗取触摸事件 – vilpe89
内容高度是否大于您的视图屏幕的高度? – Inducesmile
@NollyJ不,我不这么认为。 –