如何在滚动视图下放置新项目
我有一个包含很多项目的垂直可滚动布局,工作正常。
我正在尝试将一个新的线性布局放置到屏幕底部,该布局不会成为可滚动布局的一部分。
也就是说,它会位于底部(就像广告视图一样),独立于可滚动部分。 我只能将它放在滚动视图内。
如何将其放置在下面,以便它始终可见?
I have a vertical scrollable layout with lots of items, working fine.
I am trying to place a new linearlayout to the bottom of the screen that would NOT be part of the scrollable layout.
That is, it would sit on the buttom (like an adview) independent of the scrollable part.
I was only able to place it inside the scrollView.
How can I place it below, so it would always visible ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用RelativeLayout,并像这样组织它:
技巧在于ScrollView 的放置,同时它与屏幕顶部对齐并且位于下部固定的LinearLayout 上方。它就是有效的。
Use a RelativeLayout, and organize it like this:
The trick is in the ScrollView placement, at the same time it is aligned with the top of the screen AND above the lower, fixed, LinearLayout. It just works.
像这样的:)
您将使用 android:id=bottom 将底部内容添加到底部 LinearLayout :)
something like this :)
You will add your bottom content to the bottom linearLayout with the android:id=bottom :)
如果您使用垂直
LinearLayout
来保存可滚动布局,那么您可以将 adview 添加到可滚动布局下方的LinearLayout
中,它将显示在屏幕底部。 (假设您的权重设置正确,并且滚动布局设置为WRAP_CONTENT
)RelativeLayout
将允许您将广告视图设置为与可滚动布局的底部对齐同样,但您仍然需要确保可滚动布局设置为 WRAP_CONTENT ,这样它就不会自动占据整个屏幕。If you used a vertical
LinearLayout
to hold the scrollable layout, then you could add the adview to theLinearLayout
below the scrollable layout and it would appear at the bottom of the screen. (assuming your weights are set correctly,and the scroll layout is set toWRAP_CONTENT
)A
RelativeLayout
would allow you to set the adview to align itself with the bottom of the scrollable layout as well, but you would still need to make sure the scrollable layout was set toWRAP_CONTENT
so it didn't automatically take up the entire screen.这对我有用
This is worked for me