그래서 조합을 시도하려고합니다. 보기이 설정되었습니다. 그들은 끊임없이 의 수직 목록 Textviews 서로 그 아래에 다음 수평 상단 에 버튼 및 EDITTEXT 상자가 있어야합니다. 수직리스트는 사용자 (이 일어나는 동안 계속 표시한다 상단의 버튼과 글고 )를 TextViews 통해 아래로 스크롤 할 수있게하는 있는 ScrollView 묶어야한다.스크롤보기 내에서 수평 및 수직 선형 레이아웃
protected void initLayout() {
// Declaring the vertical layout
verticalLayout=new LinearLayout(this);
verticalLayout.setOrientation(LinearLayout.VERTICAL);
//Declaring the horizontal layout
horizontalLayout=new LinearLayout(this);
horizontalLayout.setOrientation(LinearLayout.HORIZONTAL);
//set the main view as horizontal at the top
setContentView(horizontalLayout);
//Declaring the scroll view
ScrollView scrollView= new ScrollView(this);
scrollView.addView(verticalLayout);
//set the scroll view
setContentView(scrollView);
//declare and add button to horizontal view
theButton= new Button(this);
theButton.setText("Add Joke");
horizontalLayout.addView(theButton);
//declare and add edittext to horizontal view
theEditText= new EditText(this);
theEditText.setLayoutParams(new LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT));
horizontalLayout.addView(theEditText);
}
나는 setContentView에 잘못 될 수도 있지만 완전히 확신하지는 않는다고 생각합니다. 누군가에게 많이 감사 할 충고가 있다면
에 오신 것을 환영합니다. 코드에 어떤 문제가 있습니까? 당신이 얻는 결과는 무엇이며, 의도 된 결과와 다른 점은 무엇입니까? 감사합니다. – dic19
. 코드는 편집 텍스트를 표시하고 있으며 버튼과 편집 텍스트는 표시되지 않습니다. 의도 한 결과는 edittext와 버튼이 상단에 있고 사용자가 textviews를 스크롤 할 때 거기에 머물러 있다는 것입니다. – algorhythm