我正在应用程序中制作警报对话框。由于警报对话框中存在更多文本,我想在警报对话框中放置垂直滚动条。我尝试了很多选项,但没有任何效果。请告诉我如何解决这个问题问题。这是代码:
AlertDialog.Builder HelpOnButtonDialog ;
HelpOnButtonDialog = new AlertDialog.Builder(this);
TextView HelpOnButtonView = new TextView(this);
HelpOnButtonView.setSingleLine(false);
HelpOnButtonView.setTextColor(getResources().getColor(R.color.dark_green));
HelpOnButtonView.setText("hello");
Button HelpOnButton = new Button(this);
HelpOnButton.setHeight(20);
HelpOnButton.setWidth(20);
HelpOnButton.setText("Ok");
HelpOnButton.setOnClickListener(HelpOnButtonClickListener);
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
linearLayout.setOrientation(1);
linearLayout.setBackgroundColor(getResources().getColor(R.color.black));
linearLayout.addView(HelpOnButtonView);
linearLayout.addView(HelpOnButton);
ScrollView sv = new ScrollView(this);
sv.pageScroll(0);
sv.setBackgroundColor(0);
sv.setScrollbarFadingEnabled(true);
sv.setVerticalFadingEdgeEnabled(false);
sv.addView(linearLayout);
alertHelp = HelpOnButtonDialog.create();
alertHelp.setView(sv);
alertHelp.show();