Android 布局无法正常工作 [英] Android-layout does not work properly
问题描述
我正在使用文件 main.xml
在 Android 中设计 UI.我不知道为什么最后一个 TextView
(id: ImageDescription) 不起作用.如果我删除 ImageView
标签,最后一个 TextView
将再次工作.这是我的截图.第一个在没有 ImageView
标签时,第二个在有 ImageView
I'm using file main.xml
to design UI in Android. I don't know why the last TextView
(id: ImageDescription) doesn't work. If I delete ImageView
tag, the last TextView
will work again.
Here is my screenshot. the first in when no ImageView
tag, and the second when has ImageView
ImageView tag">
如你所见,当有图像时,我看不到行图像描述符:卡通老虎
.这是我的 main.xml
:
As you see, when has image, I cannot see line Image descriptor: a cartoon tiger
.
Here is my 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>
谢谢你的帮助:)
推荐答案
您正在将您的 imageDescription textview 添加到 imageview 下方,并且您的滚动视图也同时具有 fill_parent 和 hight,一旦尝试此操作
You are adding your imageDescription textview below imageview and that too your scrollview has both with and hight as fill_parent, once try this
<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
参数.
I think image is too big, if it's the case try by specifying layout:weight
parameter for both image and text view in proper percentage.
这篇关于Android 布局无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!