Android的:在按钮列表视图或屏幕底部的结束 [英] Android: Button at the end of listview OR bottom of screen

查看:167
本文介绍了Android的:在按钮列表视图或屏幕底部的结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的Andr​​oid应用程序的要求,一个按钮,在列表的底端。因此用户必须滚动槽整个列表(也可能看到更多的答案),它是故意的。因此,我添加的按钮作为一个ListView页脚。

I have a requirement for my android application that a button is at the bottom end of the list. That is done on purpose so users have to scroll trough the entire list (and possibly see more answers). Therefore I added the button as a listview footer.

此所有工作正常,但在某些情况下,该列表是太短(只有3-4项中),这样的按钮将结束有关该屏幕的中途。我想是该按钮位于列表视图的结尾(因此,如果在列表中足够的项目,用户只能看到按钮,当他向下滚动),但是当在ListView只包含几个项目按钮,将自我修复到屏幕的底部。

This all works fine but in some cases the list is too short (only 3-4 items in it) so the button will end up about midway of the screen. What I would like is that the button is at the end of the listview (so if enough items in the list, the user can only see the button when he scrolls down) but when the listview only contains a few items the button will fix itself to the bottom of the screen.

要给我想要的想法:

onCreate() {
   if (button.getyposition() > screen.getyposition()) { // example methodnames!
      // Button at the bottom of the listview (many items)
   }
   else {
      // Button at the bottom of the screen (few items in listview)
   }
}

问题的关键是,我不知道它是否是可能的,从哪里开始。任何人都可以给我一些方向在哪里看,甚至更好一块样品code的?在此先感谢!

The point is, I don't know if it's possible and where to start. Could anyone give me some directions where to look or even better a piece of sample code? Thanks in advance!

编辑:

我添加的图片,以澄清我的问题。我希望这会更有意义!

I added a picture to clarify my problem. I hope this makes more sense!

正如你所看到的,它看起来按钮按下一半在屏幕上用很奇怪。我希望按钮是在屏幕的底部,但(!)当列表视图中包含更多的项目,我希望它出现在列表视图的底部(因此在第一,要关闭屏幕)

As you can see, it looks quite strange with the button halfway on the screen. I want the button to be at the bottom of the screen BUT (!) when the listview contains more items I want it to appear at the bottom of the listview (so at first, be off screen)

希望这有助于画面!

推荐答案

的ListView 高度 FILL_PARENT 并添加按钮与使用 addFooterView()页脚

如果您有只显示按钮的要求当列表滚动到年底,那么你可以看看这个帖子,并使用逻辑来显示/隐藏页脚视图(即设置 View.GONE 的页脚隐藏它,和 View.VISIBLE 显示它)

If you have the requirement that you only show the Button when the List is scrolled to the end, then you can look at this post and use the logic to show/hide the footer view (ie, set View.GONE on the footer to hide it, and View.VISIBLE to show it)

这篇关于Android的:在按钮列表视图或屏幕底部的结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆