how to scroll a big imageView in ScrollView
2011-09-05 11:21
267 查看
在做项目 “Heal Your Body” 的时候发现,我无法滚动显示一张大图片,把它放在scrollview里面,它一直不显示。改在程序设置imageView的background,发现它只显示一部分,scrollview 又不滚动。
很郁闷,不知道为什么,今天找一个帖子,好像讲的是同一个问题:
http://stackoverflow.com/questions/3058164/android-scrolling-an-imageview
经过实验发现:不是同一个问题。
后来发现,还是可以把ImageView放在ScrollView里面的:
<ScrollView
style="@style/PDFScrollViewStyle"
android:background="@drawable/lightblue"
android:layout_alignParentTop="true"
android:layout_marginTop="112dp"
>
<ImageView
android:id="@+id/introductionPNG"
style="@style/PDFImageViewStyle"
/>
</ScrollView>
注意你必须在代码里设置 introductionPNG.setBackgroundResource(R.drawable.introduction_1000);
如果直接写android:src="@drawable/introduction_1000" 这样也可以实现,不过当你滚动scrollview的时候,你会发现,可以滚动超出imageView的实际高度,也就是说scrollView可以滚动的高度远远高于imageView中图片的高度。
很郁闷,不知道为什么,今天找一个帖子,好像讲的是同一个问题:
http://stackoverflow.com/questions/3058164/android-scrolling-an-imageview
经过实验发现:不是同一个问题。
后来发现,还是可以把ImageView放在ScrollView里面的:
<ScrollView
style="@style/PDFScrollViewStyle"
android:background="@drawable/lightblue"
android:layout_alignParentTop="true"
android:layout_marginTop="112dp"
>
<ImageView
android:id="@+id/introductionPNG"
style="@style/PDFImageViewStyle"
/>
</ScrollView>
注意你必须在代码里设置 introductionPNG.setBackgroundResource(R.drawable.introduction_1000);
如果直接写android:src="@drawable/introduction_1000" 这样也可以实现,不过当你滚动scrollview的时候,你会发现,可以滚动超出imageView的实际高度,也就是说scrollView可以滚动的高度远远高于imageView中图片的高度。
相关文章推荐
- How to load an ImageView by URL in Android
- how to scroll a ScrollViewer at design time in Blend to manually design content for it that goes beyond the visible view
- How to scroll an image, if it does not fit in the display
- How to view or edit pdf/image metadata from command line on Linux
- Units Problem: How to read text size as custom attr from xml and set it to TextView in java code
- [eZ publish] How to modify the $view_parameters valus in the template.
- How to play video with AVPlayerViewController (AVKit) in Swift
- [转]How to Create a Thumbnail Picture Library View in SharePoint 2007
- How to view include_directories in CMake
- How to Display Image In Picturebox in VC++ from Iplimage and Mat
- How to disable vertical scrolling in UIScrollView (Obj-C)
- How to Render Image Buffer in Android NDK Native Code
- how to do graphics in java(quote from big java, 5e)?
- how to implement gesture detector onfling in webview in android - Stack Overflow
- HOWTO Splash image in GRUB
- How to invoke the method of managed bean and render view in JSF when we are outside the lifecycle of JSF
- How to View MySQL Temp Files and Temp Tables in Linux
- How to popup a UIPickerView from the bottom of a UIScrollView in response to UITextField selection
- 自定义(手动调整).net中图像的调色板(How to adjust (customize) image's palette in .net?)
- How to use jquery or ajax to update razor partial view in c#/asp.net for a MVC project