을 복제하는 것을 시도하고있다
for(int i = 0; i < 5; i++)
{
// Creating my linear layouts & views
lls = new LinearLayout(this);
llv = new LinearLayout(this);
lls.setOrientation(LinearLayout.VERTICAL);
// Adding image view
imgStory = new ImageView(this);
imgStory.setImageResource(GetImage(i));
imgStory.setLayoutParams(new LayoutParams(width, width));
lls.addView(imgStory);
// adding textview, which is scrollable
txtStory = new TextView(this);
txtStory.setText(unescape(story.get(i)));
txtStory.setTextColor(getResources().getColor(R.color.orange));
txtStory.setPadding((int)padding, (int)padding, (int)padding, (int)padding);
txtStory.setMovementMethod(new ScrollingMovementMethod());
//txtStory.setVerticalScrollBarEnabled(true);
//txtStory.setVerticalFadingEdgeEnabled(false);
lls.addView(txtStory);
// Adding views to my view flipper
llv.addView(lls);
viewFlipper.addView(llv, i);
}
XML 코드를 복제하는 것을 시도하고있다 XML 코드입니다 최상위 부모. 그래서,이 같은 일이 :
// Creating my linear layouts & views
lls = new ScrollView(this); // This wraps your textView
llv = new LinearLayout(this);
lls.setOrientation(LinearLayout.VERTICAL);
참고 :이이 테스트되지 않은 상태입니다
// Creating my linear layouts & views
lls = new LinearLayout(this);
llv = new ScrollView(this); // This looks like the view you're adding to the viewFlipper
lls.setOrientation(LinearLayout.VERTICAL);
또는 당신이 스크롤하려는 단지 텍스트의 경우, 최초의 LinearLayout있는 ScrollView을합니다. 그냥 아이디어를 주려고. 이 기능을 사용하려면 ScrollView에 더 많은 레이아웃 매개 변수를 지정해야 할 수도 있습니다. 그들이 설정에 대한 얘기를 어디
또한 this post 좀 걸릴 수 있습니다 :
textView.setMovementMethod(new ScrollingMovementMethod())
이 doesnit은 나를 TEH있는 ScrollView에 방향을 설정하는 것을 허용하지, 제대로 작동. 또한 이미지와 텍스트 뷰를 스크롤 할 수있게 만들 것입니다. 이상적으로는 ScrollView를 피하기를 좋아합니다. xml에서 볼 수 있듯이 완벽하게 작동했습니다. 감사. –
나는 내 대답에서 언급 한 것처럼 TextView를 ScrollView에 랩핑 할 수 있습니다. 이것은 이론적으로 잘 작동하고 많은 두통을 줄여야합니다. 어쨌든, 당신이 그것을 이해하기를 바랍니다. – SBerg413
업데이트 된 답변 setMovementMethod()를 사용할 수 있습니다. – SBerg413