Java 警报对话框内部的线性布局不滚动
我在警报对话框中设置了一个线性布局,其中基本上有一些编辑文本 我面临的问题是,我无法向下滚动查看动态创建的每个编辑文本 以下是片段:Java 警报对话框内部的线性布局不滚动,java,android,android-linearlayout,android-alertdialog,Java,Android,Android Linearlayout,Android Alertdialog,我在警报对话框中设置了一个线性布局,其中基本上有一些编辑文本 我面临的问题是,我无法向下滚动查看动态创建的每个编辑文本 以下是片段: Context context = this.getApplicationContext(); LinearLayout layoutCreateMerch = new LinearLayout(context); layoutCreateMerch.setOrientation(LinearLayout.VERTICAL);
Context context = this.getApplicationContext();
LinearLayout layoutCreateMerch = new LinearLayout(context);
layoutCreateMerch.setOrientation(LinearLayout.VERTICAL);
layoutCreateMerch.setVerticalScrollBarEnabled(true);
final AlertDialog.Builder alert = new AlertDialog.Builder(Act.this);
alert.setTitle("Submit");
final EditText Name = new EditText(Act.this);
final EditText Desc = new EditText(Act.this);
...
...
那么,如何在运行时在此警报对话框的线性布局中添加滚动视图
我认为LinearLayouts不需要滚动条/视图,但这不适合我:|
此外,膨胀这将是另一种选择,但现在..我可以做些什么呢
感谢阅读……) 理论上是这样的:
ScrollView scroll = new ScrollView(context);
scroll.setBackgroundColor(android.R.color.transparent);
scroll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
scroll.addView(yourLinearLayout);
因此,基本上只需将linearLayout设置为ScrollView,最后将其设置为dialogView
alertDialog.setView(scroll);
理论上是这样的:
ScrollView scroll = new ScrollView(context);
scroll.setBackgroundColor(android.R.color.transparent);
scroll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
scroll.addView(yourLinearLayout);
因此,基本上只需将linearLayout设置为ScrollView,最后将其设置为dialogView
alertDialog.setView(scroll);
请使用
包装布局。请使用
包装布局。请共享用于将线性布局添加到对话框的代码请共享用于将线性布局添加到对话框的代码