0

我在我的 xml 文件中使用了相对布局和滚动视图。当我单击“获取含义”按钮时,我得到命令的描述,但数据被重叠。请提出一些解决方案。我的布局 xml 文件是:

<?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="fill_parent"
    android:background="@drawable/img7"
     >

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="490dip"
    android:orientation="vertical" >
     <Button
        android:id="@+id/button1"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:text=""
        android:background="@drawable/house1" />
     <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:layout_alignBottom="@+id/button1"
        android:layout_alignParentLeft="true"
        android:text="Enter Unix Command"
        android:textColor="#FF0000" 
        android:textSize="25sp"
        />

    <AutoCompleteTextView
        android:id="@+id/autoCompleteTextView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/textView1"
        android:layout_marginTop="14dp"
        android:ems="10"
        android:hint="Start Typing Here........"
        android:textColor="#FF0000" >

        <requestFocus />
    </AutoCompleteTextView>

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/autoCompleteTextView1"
        android:text="Get Meaning"

        android:drawableLeft="@drawable/searchpic1"
        android:textColor="#FF0000"
        android:textSize="20sp" />
    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/button2"

        android:src="@drawable/book1" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/imageView1"
        android:text=""
        android:textColor="#FF0000"
         />
    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:text="Cympac Software Solutions Pvt Ltd"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#228b22"
        android:background="#FFFFFF" 
        android:textStyle="bold"
        android:textSize="16sp"
        android:drawableLeft="@drawable/smallicon"/>





</RelativeLayout>

</ScrollView>

在模拟器上类似 在此处输入图像描述

4

3 回答 3

2

正如Orabig所说,只textview2放在 ScrollView 中,它应该在textview3. 并RelativeLayout用作父布局。遵循其他两个答案中的代码。我希望它会起作用

于 2012-08-25T09:27:26.100 回答
1

像这样添加layout_above用于 textview 更改代码的属性

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/imageView1"
    android:layout_above="@+id/textView3"
    android:text=""
    android:textColor="#FF0000"
/>

然后为该文本视图添加可滚动属性

yourTextView.setMovementMethod(new ScrollingMovementMethod());

如果文本需要的空间多于可用空间,它将自动滚动。

于 2012-08-25T07:16:54.587 回答
1

只需将您的 TextView 放入 ScrollView

 <ScrollView 
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:layout_below="@+id/imageView1"
   android:layout_above="@+id/textView3"
   >
   <TextView
      android:id="@+id/textView2"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:text=""
      android:textColor="#FF0000"
   />
</ScrollLayout> 
于 2012-08-25T08:17:52.257 回答