任何人都可以告訴我一種方法來實現網格視圖中的水平滾動嗎?網格視圖中的水平滾動
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. 水平滾動視圖
- 6. 網格視圖與背景圖像水平滾動
- 7. 在水平滾動視圖中替代水平滾動視圖在android
- 8. 網格水平視圖
- 9. 網格水平滾動條(浮動)
- 10. 表/集合視圖的水平滾動
- 11. 水平滾動的自定義視圖
- 12. ViewPager內部的水平滾動視圖
- 13. 內部自定義視圖水平滾動視圖不滾動
- 14. WP水平滾動網格選擇
- 15. 滾動查看滾動視圖時的水平滾動
- 16. 如何滾動到水平滾動視圖的中間
- 17. 滾動視圖中水平recyclerview的滾動問題
- 18. TabLayout或水平滾動視圖Android
- 19. 水平滾動視圖不工作
- 20. 實現水平滾動視圖onClickListener
- 21. 設置水平滾動視圖佈局
- 22. Android:如何使水平滾動視圖?
- 23. Android/Java開發 - 水平滾動視圖
- 24. 如何使水平滾動周視圖
- 25. Android獲取視圖在水平滾動視圖中的位置
- 26. Android:垂直滾動視圖中的水平列表視圖?
- 27. 水平滾動網站
- 28. 水平滾動網站
- 29. 水平滾動時保持垂直滾動條在視圖中
- 30. 在水平滾動(查看鰭狀肢)中實現網格視圖
當然,小型集合可以接受,但請不要將其稱爲GridView。它缺少一個適配器,它可以讓你無需花費幾秒鐘就可以顯示所有視圖,並且可以一次填充數百個Bitmaps。 – kaay 2012-04-05 14:32:28