任何人都可以告訴我一種方法來實現網格視圖中的水平滾動嗎?網格視圖中的水平滾動
2
A
回答
4
最後我才得以實現的Android horizontall滾動網格視圖...這裏是代碼:
public class HorizontalGridView extends Activity {
Bitmap viewBgrnd;
ImageButton img ;
Button button;
Button b1[] = new Button[100];
static int total=0;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
horizontalScrollGalleryLayout();
}
public void horizontalScrollGalleryLayout() {
Integer[] mThumbIds = {
R.drawable.image0,R.drawable.image1,R.drawable.image2,
R.drawable.image3,R.drawable.image4,R.drawable.image5,
R.drawable.image6,R.drawable.image7,R.drawable.image8,
R.drawable.image9,R.drawable.image10,R.drawable.image11,
R.drawable.image12,R.drawable.image13,R.drawable.image14,
R.drawable.image15,R.drawable.image16,R.drawable.image17,
R.drawable.image18,R.drawable.image19,R.drawable.image20,
R.drawable.image21,R.drawable.image22,R.drawable.image23,
R.drawable.image24,R.drawable.image25,R.drawable.image26,
R.drawable.image27,R.drawable.image28,R.drawable.image29,
R.drawable.image30,R.drawable.image31,R.drawable.image32,
R.drawable.image33,R.drawable.image34,R.drawable.image35,
R.drawable.image36,R.drawable.image37,R.drawable.image38,
R.drawable.image39,R.drawable.image40,R.drawable.image41,
R.drawable.image42,R.drawable.image43,R.drawable.image44,
R.drawable.image45,R.drawable.image46,R.drawable.image47,
R.drawable.image48,R.drawable.image49,R.drawable.image50,
R.drawable.image51,R.drawable.image52,R.drawable.image53,
R.drawable.image54,R.drawable.image55,R.drawable.image56,
R.drawable.image57,R.drawable.image58,R.drawable.image59,
R.drawable.image60,R.drawable.image61,R.drawable.image62,
R.drawable.image63,R.drawable.image64,R.drawable.image65,
R.drawable.image66,R.drawable.image67,R.drawable.image68,
R.drawable.image69,R.drawable.image70,R.drawable.image71,
R.drawable.image72,R.drawable.image73,R.drawable.image74,
R.drawable.image75,R.drawable.image76,R.drawable.image77,
R.drawable.image77,R.drawable.image79,R.drawable.image8,
R.drawable.image81,R.drawable.image82,R.drawable.image83,
R.drawable.image84,R.drawable.image85,R.drawable.image86,
R.drawable.image87,R.drawable.image88,R.drawable.image89,
R.drawable.image90,R.drawable.image91,R.drawable.image92,
R.drawable.image93,R.drawable.image94,R.drawable.image95,
R.drawable.image96,R.drawable.image97,R.drawable.image98,
R.drawable.image99,
};
HorizontalScrollView sv = new HorizontalScrollView(this);
LinearLayout llh = new LinearLayout(this);
llh.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams layoutParamsTV = new LinearLayout.LayoutParams(100,100);
LinearLayout.LayoutParams layoutParamsLL = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
LinearLayout.LayoutParams layoutParamsLLD = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
for(int k=0;k<mThumbIds.length;k++)
{
LinearLayout llv = new LinearLayout(this);
for (int i=0; i<4; i++) {
llv.setOrientation(LinearLayout.VERTICAL);
button = new Button(this);
try {
button.setBackgroundResource(mThumbIds[total]);
total++;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
llv.addView(button, layoutParamsTV);
//b1[k].setBackgroundResource(mThumbIds[k]);
}
//llv.addView(button, layoutParamsTV);
llh.addView(llv, layoutParamsLL);
llh.setBackgroundColor(Color.GRAY);
}
sv.addView(llh, layoutParamsLLD);
setContentView(sv);
sv.setBackgroundColor(Color.GRAY);
}
}
-1
-1
在網格視圖問題的水平滾動條在這裏通過另一種方式解決。在水平滾動視圖中的每個網格視圖中都使用Thare按鈕。
相關問題
- 1. UWP - 網格視圖內水平滾動視圖
- 2. 水平滾動頁面中的水平滾動視圖
- 3. ag網格水平滾動
- 4. 在android中水平滾動的網格視圖
- 5. Android柵格視圖水平滾動
- 6. 水平滾動視圖
- 7. android水平滾動視圖
- 8. 水平滾動視圖iOS
- 9. 添加水平滾動到動態網格視圖:Android
- 10. 網格視圖與背景圖像水平滾動
- 11. 在水平滾動視圖中替代水平滾動視圖在android
- 12. 如何製作水平滾動的網格視圖?
- 13. 網格水平視圖
- 14. ListView項中的水平滾動視圖?
- 15. 手機中的水平滾動視圖
- 16. iOS中的水平滾動視圖?
- 17. 網格水平滾動條(浮動)
- 18. 如何在水平滾動視圖中使用平滑滾動居中視圖
- 19. 水平滾動視圖繪製圖
- 20. 水平滾動圖像視圖列表
- 21. 水平滾動自定義網格
- 22. WP水平滾動網格選擇
- 23. android:chipview上的水平滾動視圖
- 24. ViewPager內部的水平滾動視圖
- 25. 水平滾動的自定義視圖
- 26. 水平滾動視圖迅速的Xcode
- 27. 表/集合視圖的水平滾動
- 28. 滾動視圖與web視圖不滾動水平
- 29. 內部自定義視圖水平滾動視圖不滾動
- 30. 滾動查看滾動視圖時的水平滾動
當然,小型集合可以接受,但請不要將其稱爲GridView。它缺少一個適配器,它可以讓你無需花費幾秒鐘就可以顯示所有視圖,並且可以一次填充數百個Bitmaps。 – kaay 2012-04-05 14:32:28