だから私はScrollView
の最初のビューとしてを持っていViewPager
ます。次のコードは正しくレンダリングされますが、単にスクロールしません。
ShadeDisplay.java
public class ShadeDisplay extends SherlockFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle ParthMehrotra) {
if (container == null) {
return null;
}
ScrollView sv = new ScrollView(getSherlockActivity());
sv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
sv.setFillViewport(true);
sv.setBackgroundColor(Color.BLACK);
LinearLayout ll = new LinearLayout(getSherlockActivity());
ll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
ll.setOrientation(LinearLayout.VERTICAL);
ImageView iv = new ImageView(getSherlockActivity());
iv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
iv.setImageResource(R.drawable.banner);
ll.addView(iv);
Pattern patern1 = new Pattern(getSherlockActivity());
patern1.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
Pattern patern2 = new Pattern(getSherlockActivity());
patern2.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
ll.addView(patern1);
ll.addView(patern2);
sv.addView(ll);
return sv;
}
}
Pattern.java
public class Pattern extends View {
Paint[] shade = new Paint[5];
public Pattern(Context context) {
super(context);
for (int i = 0; i < shade.length; i++) {
shade[i] = new Paint();
}
shade[0].setColor(Color.RED);
shade[1].setColor(Color.BLUE);
shade[2].setColor(Color.GREEN);
shade[3].setColor(Color.YELLOW);
shade[4].setColor(Color.CYAN);
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawRect(0, 0, getWidth(), getWidth() / 3, shade[0]);
canvas.drawRect(((getWidth() / 3) * 2), 0, getWidth(), getWidth(),
shade[1]);
canvas.drawRect(0, ((getWidth() / 3) * 2), getWidth(), getWidth(),
shade[2]);
canvas.drawRect(0, (getWidth() / 3), getWidth()/3, getWidth(),
shade[3]);
canvas.drawRect(getWidth() / 3, getWidth() / 3, ((getWidth() / 3) * 2),
((getWidth() / 3) * 2), shade[4]);
}
}
私は本当にばかげた何かを見落としているに違いないことを知っていますが、どこにも解決策を見つけることができません。