2012-06-10 21 views
0

我有一個關於背景圖片和Android鍵盤的問題。當使用鍵盤時膨脹的背景圖片

我的界面如下圖所示。 它的搜索功能,下面有一個列表視圖。我的問題是,無論何時您輸入搜索欄(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> 

回答

1

啓動軟鍵盤時的默認行爲是操作系統調整視圖的大小以適應新的屏幕邊界。既然你有背景圖片,結果就像你看到的那樣被捏住了。

See the documentation here on android:windowSoftInputMode ,你要的是 「adjustPan」

+0

thanx的答案的行爲。這真是奇怪,因爲如果我將android:windowSoftInputMode =「adjustPan」添加到活動中,沒有任何反應。這是清單中的代碼:<活動 \t機器人:名字= 「SearchTask。」 \t機器人:主題= 「@安卓風格/ Theme.NoTitleBar」 \t機器人:windowSoftInputMode = 「adjustPan」> – user1293618

+0

總結在scrollview中的所有內容並更改您的表格佈局高度以包裝內容。 –

1

我猜的背景的TableLayout改變形狀與視圖。嘗試將其設置爲Activity背景並使透明的背景爲TableLayout

注意:我不確定活動背景不會調整大小。