首页 > 解决方案 > 框架布局中相对布局中的滚动视图

问题描述

我有一个很大的问题。我想滚动我在相对布局中的 FrameLayout。框架布局创建 2 个图像循环,我希望每个图像都显示(在 2 列中)并且滚动视图有效。

<ScrollView
    android:fillViewport="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/frame1"/>

        </RelativeLayout>



</ScrollView>
for (int y=0; y < 3; y++) {
            for (int i = 0; i < 20; i++) {
                index = "car_0";
                final ImageView car = new ImageView(SecondActivity.this);
                car.setLayoutParams(iparams);
                car.setImageResource(R.drawable.car_0);
                car.setY(i * size.y/3-5);
                car.setX(y * size.x/3-5);
                frameLayout.addView(car);
            }

        }

标签: androidandroid-layout

解决方案


推荐阅读