我必须开发five to six
horizontal
滚动view
,在此滚动image
使用adapter
添加动态。
功能
1)图像可以将一个滚动视图拖放到另一个
2)图像可以将一个水平滚动移动到另一个视图
3)可以选择/取消选择图像
4)with all version
我正在使用此library,但有时滚动不是那么顺利(切碎)
答案 0 :(得分:1)
检查此链接可能对您有用。
1)Insert a view dynamically in a HorizontalScrollView in Android
2)http://android-er.blogspot.in/2012/07/implement-gallery-like.html
3)Horizontal ListView like Google Catalogs
答案 1 :(得分:0)
使用此代码,您可以通过编程方式将android控件添加到linearlayout,并通过xml将Horizontal Scrollview添加到Linear Layout 您将获得水平列表视图。
//My coding here.
String[] name={"PRASHANT","PRASHANT","PRASHANT","PRASHANT","PRASHANT","PRASHANT","PRASHANT"} ;
myLInearLayoutmain =(LinearLayout) findViewById(R.id.linearLayoutmain);
for(int i =0;i<6;i++)
{
LinearLayout li=new LinearLayout(getApplicationContext());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
li.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
LinearLayout.LayoutParams paramsnew = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
params1.setMargins(30, 20, 30, 0);
//add textView
valueTV = new TextView(this);
valueTV.setText(""+name[i]);
valueTV.setId(5);
valueTV.setLayoutParams(paramsnew);
valueTV.setGravity(Gravity.CENTER);
// adding Button to linear
valueB = new Button(this);
valueB.setText(""+name[i]);
valueB.setId(i);
valueB.setLayoutParams(params);
valueB.setOnClickListener(this);
valueB.setGravity(Gravity.CENTER);
// adding Imageto linear
img = new ImageView(this);
img.setImageResource(R.drawable.ic_launcher);
img.setLayoutParams(paramsnew);
//add the textView and the Button to LinearLayout
li.addView(valueTV);
li.addView(valueB);
li.addView(img);
li.setLayoutParams(params1);
myLInearLayoutmain.addView(li);
}