2012-02-22 134 views
1

我使用文件main.xml来设计Android中的UI。我不知道为什么最后的TextView(id:ImageDescription)不起作用。如果我删除ImageView标记,则最后的TextView将再次起作用。 这是我的截图。当没有ImageView标签,而第二时有ImageViewAndroid布局无法正常工作

not <code>ImageView</code> tag with <code>ImageView</code> tag

正如你看到的,在第一时有图像,我看不到线Image descriptor: a cartoon tiger。 这里是我的main.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 

    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/imageTitle" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/test_image_title"/> 

    <TextView 
     android:id="@+id/imageDate" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/test_image_date"/> 


    <ImageView 
     android:id="@+id/imageDisplay" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:contentDescription="@string/test_contentDescription" 
     android:src="@drawable/test_image"/> 

    <ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <TextView 
      android:id="@+id/imageDescription" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/test_image_description"/> 
    </ScrollView>   

</LinearLayout> 

感谢帮助我:)

+0

来自ScrollView文档'TextView类也照顾它自己的滚动,所以不需要ScrollView' – Selvin 2012-02-22 15:30:29

+2

@Selvin是的。我认为问题不是'ScrollView',因为当我删除'ScrollView'标记时,仍然没有发生任何不同:( – hqt 2012-02-22 15:44:35

+2

它非常简单明显......图像太大......它似乎在顶部有黑条,底部...也许你应该把图像和desription到另一个linearlayout,然后把这个linearlayout滚动查看... – Selvin 2012-02-22 15:48:35

回答

1

你加入以下imageview的并且过于你的滚动视图有有和HIGHT作为FILL_PARENT,一旦尝试这个

您imageDescription的TextView
<TextView 
     android:id="@+id/imageDate" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/test_image_date"/> 


    <ScrollView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 
     <TextView 
      android:id="@+id/imageDescription" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/test_image_description"/> 
    </ScrollView> 

    <ImageView 
     android:id="@+id/imageDisplay" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:contentDescription="@string/test_contentDescription" 
     android:src="@drawable/test_image"/> 

我认为图像太大,如果是这种情况,请尝试通过以适当的百分比为图像和文本视图指定layout:weight参数。

+1

是的,你的代码工作,但不是我想要的用户界面,我想在下面的图像描述。 ? – hqt 2012-02-22 15:28:49

+0

然后,只改变你的滚动视图的宽度和高度,就像在我的帖子中一样,为什么因为它试图占用父母的总体大小 – sankar 2012-02-22 15:48:36

+1

我认为图像太大,如果是这种情况,请尝试指定布局:图像和文本视图在适当的比例。 – sankar 2012-02-22 15:57:58

1

试图将XML部分

<ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 

改变

<ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 

因为你ScrollView试图那样大,高度的LinearLayout

+0

没有什么变化:( – hqt 2012-02-22 15:43:10

+1

也没有任何保证金或填充XML在你的ImageView中,但它的方式在你的TextView下。你的testimage上面和下面都没有黑色或透明条纹,将ScrollView推出可视区域? – IBoS 2012-02-22 15:55:18

+2

是的,也许我的图像有透明的三角形,但是当我把它作为墙纸时,我看不到透明的三角形如何测试它,你知道吗请教我:) – hqt 2012-02-22 16:29:07

1

我有我的问题的另一个答案,我发布在这里谁看过我的帖子,需要更多的答案。我使用android:adjustViewBounds="true"财产:)

相关问题