Android两层重叠滚动布局,如Airbnb房间细节布局
我想有一个两层重叠的滚动布局像Airbnb房间细节布局Android两层重叠滚动布局,如Airbnb房间细节布局,android,android-layout,Android,Android Layout,我想有一个两层重叠的滚动布局像Airbnb房间细节布局 类似Airbnb的重叠滚动: 但是我的XML布局文件输出以下结果: 这是我的布局代码: <android.support.design.widget.AppBarLayout android:id="@+id/appBarLayout" android:layout_width="match_parent" android:layout_height="wrap_content" androi
类似Airbnb的重叠滚动:
但是我的XML布局文件输出以下结果:
这是我的布局代码:
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<ImageView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="280dp"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="@drawable/height_360_2" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="always">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:cardElevation="8dp"
app:contentPadding="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lineSpacingExtra="8dp"
android:text="@string/person_intro" />
</android.support.v7.widget.CardView>
</android.support.v4.widget.NestedScrollView>
</FrameLayout>
由于我的评论帮助解决了以下问题:
这两个人看起来很像我。我看到的区别是你的一路走到了顶端,对吧?尝试添加marginTop=“50dp”并查看是否有任何变化 添加正确的
marginTop
修复了它:
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="150dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
app:cardElevation="8dp"
app:contentPadding="16dp">
这两个看起来很像我。我看到的区别是你的一路走到了顶端,对吧?尝试添加marginTop=“50dp”
,看看是否有任何变化。@Vucko谢谢。很好,现在可以在Cardview Cool中添加marginTop,然后我会将我的评论移动到答案,这样你就可以通过接受来奖励我。没问题:)谢谢提醒提示,我确实添加了marginTop,但在中,滚动不会超过marginTop区域。如果顶部滚动的cardview后面有工具栏和图像ViewPager,则触摸事件似乎不会传递到工具栏和viewpaer。有什么办法解决这个问题吗?嗯,我不太确定。。。您可以尝试在线搜索类似“将onTouch事件传递给父级”或类似的内容。