2012-02-07 65 views
3

我试图在其中使用ScrollView和ImageView。 我为它的XML代码是这样的:ScrollView填充

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:fillViewport="true" 
    android:layout_gravity="right" > 

     <ImageView 
      android:id="@+id/tapjoy_dialog_image" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="10dp" 
      android:src="@drawable/untitled" /> 

</ScrollView> 

奇怪的是,当我运行它时,图像显示了顶部和底部是一个非常宽的填充。要理解我的意思,请查看我附加的截图。

ScrollView snapshot

我该如何解决这个问题?

更奇怪的是:

  1. 当我删除了滚动,并留下ImageView的唯一,它不垫和很好地工作。

  2. 当我删除I​​mageView并放置一个大的textView,而不是垫和工作很好。

所以,我认为这个问题是有些关联的滚动型和ImageView的组合...

我试图把在ImageView的形象是这样的: enter image description here

+0

使用relativelayout – NagarjunaReddy 2012-02-07 13:59:18

+0

你是什么意思?只需使用RelativeLayout包装ImageView? 如果是这样,我现在试过了,它不工作... – user1028741 2012-02-07 14:09:29

+0

删除android:fillViewport =“true”或只是将其设置为false并运行它。 – 2012-02-07 14:13:32

回答

6

添加android:adjustViewBounds="true"ImageView添加一个父布局。

+1

谢谢你,我花了这么多时间后,线回答做了诡计...... :) – user1028741 2012-02-08 03:51:55

0

//为滚动视图

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:fillViewport="false" 
    android:layout_gravity="right" > 
<LinearLayout android:layout_width="fill_parent" 
      android:layout_height="fill_parent" > 
     <ImageView 
      android:id="@+id/tapjoy_dialog_image" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="10dp" 
      android:src="@drawable/untitled" /> 

</LinearLayout> 
</ScrollView> 
+0

我现在试过了,仍然一样... – user1028741 2012-02-07 14:08:07

+0

@ user1028741更改android:fillViewport =“false” – 2012-02-07 14:13:44

+0

我试图删除fillViewort - 它没有改变任何东西 - 仍然是同样的东西... – user1028741 2012-02-07 14:24:28