2011-08-30 32 views
0

我正在做一個Android應用程序,我應該在底部放置兩個按鈕,當彈出鍵盤時,他們需要移動到鍵盤佈局的上方,再次返回到底部頁。怎麼樣?如何在頁面佈局中移動頁腳

回答

0

查看AndroidManifest中activity元素的android:windowSoftInputMode屬性。在我的應用程序中,我使用此代碼:

<activity android:name="MyActivity" 
      android:label="@string/app_name" 
      android:windowSoftInputMode="adjustResize" 
      android:configChanges="orientation|keyboardHidden" 
      android:launchMode="singleInstance" 
      android:screenOrientation="portrait"> 

注意android:windowSoftInputMode="adjustResize"行。在這裏閱讀更多:http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft

0

如果你總是想顯示在屏幕上,那麼你可能要考慮使用RelativeLayout。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 

<com.admob.android.ads.AdView 
     android:id="@+id/ad" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     app:backgroundColor="#000000" 
     app:primaryTextColor="#FFFFFF" 
     app:secondaryTextColor="#CCCCCC" 
     android:layout_alignParentTop="true" 
    /> 

<!-- TextView below that --> 

<TextView 
android:id="@+id/widget28" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="Input Amount:" 
android:layout_marginLeft="10dip" 
android:layout_marginTop="10dip" 
android:layout_marginRight="10dip" 
android:layout_below="@id/ad" 
android:textSize="16dip" 
android:textStyle="bold"> 
</TextView> 

</RelativeLayout>