如何修复我的线性布局以在内容超出视图时向下滚动

我正在动态地向适配器添加视图,当视图超过屏幕边界时,我无法看到完整视图。

我试过了,没有任何运气。android:isScrollContainer="true"android:scrollbars="vertical"

public void onAddField(View v) {
        final LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        final View rowView = inflater.inflate(R.layout.field, null);
        spin = rowView.findViewById(R.id.type_spinner2);
        weightLayout = rowView.findViewById(R.id.myLayout);
        getdata();
        spin.setAdapter(new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_spinner_dropdown_item, arrayList2));
        parentLinearLayout.addView(rowView, parentLinearLayout.getChildCount() - 1);
 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:background="#E5E5E5"
        android:orientation="vertical"
        android:scrollbars="vertical"
        android:isScrollContainer="true">


30秒到达战场
浏览 69回答 1
1回答

牛魔王的故事

尝试使用这个:&nbsp;<LinearLayout &nbsp;&nbsp;&nbsp;&nbsp;xmlns:android="http://schemas.android.com/apk/res/android" &nbsp;&nbsp;&nbsp;&nbsp;android:id="@+id/card" &nbsp;&nbsp;&nbsp;&nbsp;android:layout_width="match_parent" &nbsp;&nbsp;&nbsp;&nbsp;android:layout_height="wrap_content" &nbsp;&nbsp;&nbsp;&nbsp;android:orientation="horizontal"> &nbsp;&nbsp;&nbsp;&nbsp;<ScrollView &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:layout_width="match_parent" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:layout_height="wrap_content"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<LinearLayout &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:layout_width="match_parent" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:layout_height="wrap_content" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:orientation="vertical"&nbsp;> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<TextView &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:id="@+id/textView" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:layout_width="match_parent" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:layout_height="wrap_content" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:layout_margin="50dp" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:text="TextView"&nbsp;/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</LinearLayout> &nbsp;&nbsp;&nbsp;&nbsp;</ScrollView> </LinearLayout>这样,您的滚动视图将随您的线轮布局一起扩展。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java