使用键盘时膨胀的背景图片

时间:2012-06-10 20:16:32

标签: android background keyboard android-tablelayout

我对背景图片和Android键盘有疑问。

我的界面如下图2所示。 它是一个搜索功能,下面有一个列表视图。我的问题是,无论何时键入搜索栏(EditText),键盘都会出现并更改背景图片。它看起来很糟糕和臃肿。你怎么告诉android在使用键盘时不要改变背景图片(只需让键盘滑过背景图片而不改变它)?

背景应如何:http://tinypic.com/view.php?pic=2nsxowx&s=6

键盘会将背景更改为此混乱:http://tinypic.com/view.php?pic=23huck0&s=6

这是我的xml文件:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_search_task"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/searchable"
android:gravity="center|top"
android:orientation="vertical" 
android:stretchColumns="1"
android:weightSum="1.0"
>


<TableRow
>
    <EditText
        android:id="@+id/searchText"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.8"
        android:hint="@string/SearchTaskHint" />

    <Button
        android:id="@+id/searchButton"
        android:layout_width="0dip" 
        android:layout_height="fill_parent"
        android:layout_gravity="center"
        android:layout_weight="0.2"
        android:text="@string/Search" />


 </TableRow> 

 <TableRow>
 <TextView
 android:layout_width="wrap_content" 
 android:layout_height="5dp">
   </TextView>
 </TableRow> 
 <TableRow
 android:paddingLeft="40dp">

 <TextView 
   android:id="@+id/search_task_column_names"
   android:layout_width="0dip" 
   android:layout_height="wrap_content" 
   android:textStyle="bold"

   android:layout_weight="0.33"
  >
    </TextView>

 <TextView 
   android:id="@+id/search_task_column_names1"
   android:layout_width="0dip" 
   android:layout_height="wrap_content" 
   android:textStyle="bold"

   android:layout_weight="0.33">
    </TextView>

 <TextView 
   android:id="@+id/search_task_column_names2"
   android:layout_width="0dip" 
   android:layout_height="wrap_content" 
   android:textStyle="bold"

   android:layout_weight="0.33"
  >
    </TextView>

  </TableRow>


  <TableRow
  android:paddingLeft="25dp"
  android:paddingRight="30dp" >
  <ListView
   android:id="@+id/search_task_list"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"

   android:gravity="center"

    />
  </TableRow> 
  </TableLayout>

2 个答案:

答案 0 :(得分:1)

我猜测TableLayout更改形状的背景与视图一致。尝试将其设置为Activity背景,并使TableLayout的背景透明。

注意:我不确定活动背景是否会调整大小。

答案 1 :(得分:1)

启动软键盘时的默认行为是操作系统调整视图大小以适应新的屏幕范围。由于你有一张背景图片,结果会像你看到的一样被挤压。

See the documentation here on android:windowSoftInputMode 你想要的行为是“adjustPan”

相关问题