Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android:ImageView在滚动视图中按屏幕宽度缩放_Android_Imageview_Scrollview_Image Scaling - Fatal编程技术网

Android:ImageView在滚动视图中按屏幕宽度缩放

Android:ImageView在滚动视图中按屏幕宽度缩放,android,imageview,scrollview,image-scaling,Android,Imageview,Scrollview,Image Scaling,我对android编程很陌生,我偶然发现我的布局有一个问题 起初,我有一个线性布局,带有文本视图,2个按钮,还有一个图像视图缩放,以适应屏幕 现在我想把它放在一个滚动视图下,这样图像视图就可以按屏幕的宽度进行缩放 没有scrollview一切都很顺利,但是有了scrollview,我的imageview就不再缩放了 我做错了什么?我在StackOverflow上尝试了许多解决方案,但我无法让它与滚动视图一起工作。提前谢谢 <?xml version="1.0" encoding="utf-

我对android编程很陌生,我偶然发现我的
布局有一个问题

起初,我有一个
线性布局
,带有
文本视图
,2个
按钮
,还有一个
图像视图
缩放,以适应屏幕

现在我想把它放在一个
滚动视图下
,这样
图像视图
就可以按屏幕的宽度进行缩放

没有
scrollview
一切都很顺利,但是有了
scrollview
,我的
imageview
就不再缩放了

我做错了什么?我在StackOverflow上尝试了许多解决方案,但我无法让它与
滚动视图一起工作。提前谢谢

<?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。此滚动视图将包含一个布局,所有其他视图将放置在其中


谢谢你的帮助!我尝试将RelativeLayout作为父视图,然后将ScrollView作为子视图,layout_alignParentTop=true,将LinearLayout(包含所有文本/按钮/图像视图)作为ScrollView的子视图。但还是没有变化。我还得到警告,ScrollView是无用的。我一定是做错了什么!这回答了我的问题,谢谢你的帮助!