[英]Android: ImageView scale to screen width within a ScrollView
我是android编程的新手,偶然发现了一个layout
问题。
首先,我有一个Linearlayout
,带有textview
,2个buttons
和一个可缩放以适合屏幕的imageview
。
现在,我想将其放置在scrollview
,以便可以将imageview
缩放到更大的比例(缩放到屏幕的宽度)。
没有scrollview
一切都很好,但是有了scrollview
,我的imageview
不再缩放了。
我做错了什么? 我在StackOverflow上尝试了许多解决方案,但无法使其与ScrollView
一起使用。 提前致谢!
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/pageno" />
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/texta" />
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/textb" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="@drawable/page1" />
</LinearLayout>
</ScrollView>
使LinearLayout / RelativeLayout成为父视图。 在其中进行滚动视图并设置alignparentTop = true。 该scrollView将包含一个布局,所有其他视图都将放置在该布局中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.