私は最近このようなことをしなければなりませんでした。うまくいけば、これがあなたを助けるかもしれません:
// Create a ScrollView so the dialog can scroll
ScrollView scrollView = new ScrollView(getActivity());
scrollView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
// Create layout for the controls in the dialog
LinearLayout lay = new LinearLayout(getActivity());
lay.setOrientation(LinearLayout.VERTICAL);
lay.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
// Create a TextView to add to the dialog
TextView productNameLabel = new TextView(getActivity());
productNameLabel.setText("Some text");
productNameLabel.setGravity(Gravity.CENTER);
productNameLabel.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT, 1f));
// Add the views to the layout
lay.addView(productNameLabel);
// Add the layout to the scrollview
scrollView.addView(lay);
// Create the dialog
final AlertDialog.Builder b = new AlertDialog.Builder(getActivity())
.setTitle("Dialog Title")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Do something when OK is clicked
}
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Do something when Cancel is clicked
}
});
// Tell the dialog to use the ScrollView
b.setView(scrollView);
// Show the dialog
b.create().show();
それはおそらく最善の方法ではありませんが、私はAndroidが初めてで、私が行ったことはうまくいきます:)