所以我试图实现一个滑动的imageview。 我不需要它全屏。 只是上部屏幕的一部分。 所以我在这样的活动中有一个imageview -
<ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:src="@drawable/ic_launcher" />现在android:src是我创建的drawable例如。 那么我可以创建一个图像数组并将该数组名称作为源值吗? 如果是,那么我怎样才能让图像显示在另一个之后呢? 我不希望显示缩略图。 活动开始后,图像应该像您在网站上看到的那样开始显示。
So I am trying to implement a sliding imageview. I dont need it to be fullscreen. Just some part of the upper screen. So I have out an imageview in the activity like this -
<ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:src="@drawable/ic_launcher" />Now android:src is an drawable I created for example. So is it possible that I can create an array of images and give that array name as the source value? If yes then how can I make the images show on after another? I dont want thumbnails to be displayed. As soon as the activity starts the images should start showing up just like you would see on a website normally.
最满意答案
只需使用一个ViewPager ,并为其FragmentPagerAdapter的每个片段设置一个包含imageView的布局,并根据其位置显示正确的图像。
请注意,如果图像太大,则应在显示图像之前对其进行下采样。
另请注意,您应该硬引用片段中的位图并存储片段,因为它将使用越来越多的内存,您拥有的片段越多。
通常,您应该至少允许应用程序引用3个图像,因为应该允许用户从当前片段左右移动。
just use a ViewPager , and for each fragment of its FragmentPagerAdapter set it to have a layout that includes the imageView and show the correct image based on its location.
note that if the images are too large, you should downsample them before showing them.
also note that you should hard reference to the bitmaps in the fragments and also store the fragments, as it will use more and more memory, the more fragments you have.
in general, you should at least allow the app to have reference to 3 images, since the user should be allowed to go right and left from the current fragment.
我正在尝试在Android中实现滑动imageview(I am trying to implement sliding imageview in Android)所以我试图实现一个滑动的imageview。 我不需要它全屏。 只是上部屏幕的一部分。 所以我在这样的活动中有一个imageview -
<ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:src="@drawable/ic_launcher" />现在android:src是我创建的drawable例如。 那么我可以创建一个图像数组并将该数组名称作为源值吗? 如果是,那么我怎样才能让图像显示在另一个之后呢? 我不希望显示缩略图。 活动开始后,图像应该像您在网站上看到的那样开始显示。
So I am trying to implement a sliding imageview. I dont need it to be fullscreen. Just some part of the upper screen. So I have out an imageview in the activity like this -
<ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:src="@drawable/ic_launcher" />Now android:src is an drawable I created for example. So is it possible that I can create an array of images and give that array name as the source value? If yes then how can I make the images show on after another? I dont want thumbnails to be displayed. As soon as the activity starts the images should start showing up just like you would see on a website normally.
最满意答案
只需使用一个ViewPager ,并为其FragmentPagerAdapter的每个片段设置一个包含imageView的布局,并根据其位置显示正确的图像。
请注意,如果图像太大,则应在显示图像之前对其进行下采样。
另请注意,您应该硬引用片段中的位图并存储片段,因为它将使用越来越多的内存,您拥有的片段越多。
通常,您应该至少允许应用程序引用3个图像,因为应该允许用户从当前片段左右移动。
just use a ViewPager , and for each fragment of its FragmentPagerAdapter set it to have a layout that includes the imageView and show the correct image based on its location.
note that if the images are too large, you should downsample them before showing them.
also note that you should hard reference to the bitmaps in the fragments and also store the fragments, as it will use more and more memory, the more fragments you have.
in general, you should at least allow the app to have reference to 3 images, since the user should be allowed to go right and left from the current fragment.
发布评论