1

我正在使用文件main.xml在 Android 中设计 UI。我不知道为什么最后一个TextView(id:ImageDescription)不起作用。如果我删除ImageView标签,最后一个TextView将再次起作用。这是我的截图。第一个在没有ImageView标签时,第二个在有标签时ImageView

不是 <code>ImageView</code> 标签 带有 <code>ImageView</code> 标签

如您所见,当有图像时,我看不到 line 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>

谢谢你帮助我:)

4

3 回答 3

1

您正在将您的 imageDescription textview 添加到 imageview 下方,并且您的滚动视图也同时具有 with 和 hight 作为 fill_parent,一旦尝试这个

 <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以适当的百分比为图像和文本视图指定参数。

于 2012-02-22T15:22:34.353 回答
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的身高一样大。

于 2012-02-22T15:32:37.793 回答
1

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

于 2012-02-23T13:10:15.743 回答