- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个父线性布局和三个子布局,每个子布局的权重为 3我想从服务器获取图像并将这些图像放置在子布局中并且它工作正常。
但是在放置图像时,每次迭代后我都会获得空间。我的意思是我将迭代图像计数并根据提醒放置这些图像。
图像看起来像这样(三个垂直布局的图像)
| | |
| |
|
|
| | |
您可以看到每张图片之间的空白。在第一次迭代中,我得到 5 张图片(比如说),在第二次迭代中,我想将图片放在每个独立布局图片的下方。
我的意思是这样的
| | |
| | |
| | |
| | |
那么如何避免空隙填充图片呢??
这是我的代码
private View setupView(View parentView) {
int itemCount = 1;
LinearLayout columnOdd = (LinearLayout) parentView.findViewById(R.id.column_odd);
LinearLayout columnEven = (LinearLayout) parentView.findViewById(R.id.column_even);
LinearLayout columnCenter = (LinearLayout) parentView.findViewById(R.id.column_center);
View itemView = inflater.inflate(R.layout.custom_view, null);
if (itemCount % 3 == 0) {
columnEven.addView(itemView);
} else if (itemCount % 2 == 0){
columnOdd.addView(itemView);
}
else if (itemCount % 1 == 0) {
columnCenter.addView(itemView);
}
itemCount++;
}
return parentView;
这就是我在布局中膨胀 View 的方式:
View v = inflater.inflate(R.layout.items, null);
v = setupView(v);
if (v != null) {
mCurrentItem++;
mViews.parentLinearLayout.addView(v);
}
最佳答案
如果有大量图像,那么您应该使用 gridview
否则您可能会遇到内存不足的异常。使用 numColumns
为 3 的 gridView。
关于android - 避开间隙并放置图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31238152/
在编写 C++ 应用程序时,我通常会限制自己使用 C++ 特定的语言功能。这主要意味着尽可能使用 STL 而不是 CRT。 对我来说,STL 比使用 CRT 更流畅且更易于维护。请考虑以下事项: st
我的 Condor 网格上有一台主机由于某种原因坏了,即在这台主机上运行的作业永远运行。我不是管理员,无法登录,因此我无法调查,也无法将其从网格中移除。我只想在我的提交文件中指定我不想在该主机上运行作
我想使用 JavaScript API 避开 route 的某些区域。我知道,路由API包含这种可能性 我使用这种方式避免了 JS API 中的某些区域 是否可以使用此处 map 的 JS API 避
我开始使用 OleDB。我正在尝试从 Excel 文件(在 C# 中)中提取大量随机数据。这是我的查询: SELECT * FROM NAMED_RANGE 但是我有很多空行。我循环删除它们,但我不太
我正在浏览互联网上所有可能的样本来解决这个问题。还是很头疼。 我只想避免在 www.mylararavelsite.com/public/ 中使用“public”并使其像 www.mylararave
如何安装并使用 mysql? 我试过: $ brew install mysql ==> Downloading https://homebrew.bintray.com/bottles/mysql-
我是一名优秀的程序员,十分优秀!