[英]FrameLayout inside Scroll view
我有一個很大的問題。 我有 60 張圖像(3 列 20 行)添加到 FrameLayout 中。 但有一個問題。 我想通過 ScrollView 滾動這些圖像。 所以我添加了滾動視圖,並在其中添加了 FrameLayout。 但是這個滾動視圖不起作用(它不滾動)。 每個圖像 ig 都很好,但一個問題是它不適合。 請幫我。
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/frame1"/>
</ScrollView>
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x/3;
int height = size.y/3;
iparams = new FrameLayout.LayoutParams(width, width);
for (int y = 0; y < 20; y++) {
for (int i = 0; i < 3; i++) {
final ImageView car = new ImageView(SecondActivity.this);
car.setImageResource(R.drawable.car_0);
car.setLayoutParams(iparams);
car.setId(i+3*y);
car.setY(y * width);
car.setX(i * width);
frameLayout.addView(car);
}
}
在這種情況下,最好將 RecyclerView 與 GridLayoutManager 一起使用
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.