Android异构gridview如pinterest? [英] Android heterogeneous gridview like pinterest?
本文介绍了Android异构gridview如pinterest?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可以使用 GridView
在Android上创建pinterest like layout我想使用 GridView
创建图像库,但我不知道它是否是很好的解决方案。我不想创建三个 LinearLayouts
(我认为这个解决方案不好: Pinterest风格的listview或者在android中的gridview )
Is it possible to create pinterest like layout on Android using GridView
? I want to create image gallery using GridView
but I am not sure if it is good solution. I do not want create three LinearLayouts
(I think that this solution is not good: Pinterest style listview or gridview in android)
任何想法;)?
推荐答案
创建如下的布局
<ScrollView...>
<LinearLayout....
android:id="@+id/linear1"
orientation="horizontal">
<LinearLayout....
android:id="@+id/linear2"
android:layout_weight="0.33"
orientation="vertical">
<LinearLayout....
android:id="@+id/linear3"
android:layout_weight="0.33"
orientation="vertical">
<LinearLayout....
android:layout_weight="0.33"
orientation="vertical">
</LinearLayout>
</ScrollView>
现在在布局中动态添加您的 ImageView
/ p>
Now add your ImageView
dynamically in layouts
linear1 = (LinearLayout) findViewById(R.id.linear1);
linear2 = (LinearLayout) findViewById(R.id.linear2);
linear3 = (LinearLayout) findViewById(R.id.linear3);
for(int i=0;i<n;i++)
{
ImageView iv = new ImageView(this);
iv.setImageResource(R.id.icon);
int j = count % 3; <----
if(j==0)
linear1.addView(iv);
else if(j==1)
linear2.addView(iv);
else
linear3.addView(iv);
}
输出:
这篇关于Android异构gridview如pinterest?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文