2012-01-24 3 views
0

連絡先に保存&キャンセルボタンを表示する方法は?あなたは、連絡先に編集した場合は

  • 保存&キャンセル]ボタンは常にトップにとどまり、 仮想キーボードの上に置きました。
  • フォーム要素は、私は同じ動作を達成したい

スクロール可能です。私は入力するために非常に長いフォームがあり、私はいつでも保存/キャンセルをユーザーにしたいと思います。

助けてください。

+0

は、あなたが正確に欲しいものを得るでしょう私の答えをチェックしたいとlayou以下

//は、ボタンバーのため..です – AAnkit

答えて

4

あなたlayout.exampleでフッターのビューを追加することによってそれを行うことができます。

http://blog.maxaller.name/2010/05/attaching-a-sticky-headerfooter-to-an-android-listview/

私はこのレイアウトを使用して同じことを達成します:

<?xml version="1.0" encoding="utf-8"?> 


    <LinearLayout android:id="@+id/linearLayout1" 
     android:layout_width="fill_parent" android:layout_height="fill_parent" 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical" android:background="#ffffff"> 
     <RelativeLayout 
      android:layout_width="fill_parent" android:layout_height="50dp"> 
      <Button "></Button> 
     </RelativeLayout> 

     <ScrollView android:layout_width="fill_parent" 
      android:layout_height="wrap_content" android:layout_weight="1"> 
      <LinearLayout android:id="@+id/linearLayout1" 
       android:layout_width="fill_parent" android:layout_height="wrap_content" 
       android:orientation="vertical" android:background="#ffffff"> 
       <RelativeLayout android:gravity="bottom" 
        android:paddingTop="40dp" android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_alignParentBottom="true" 
        android:layout_alignParentLeft="true" android:background="#ffffff" 
        android:paddingBottom="55dp"> 

        <Button ></Button> 

        <Button ></Button> 

        <Button></Button> 


        <Button></Button> 


       </RelativeLayout> 
      </LinearLayout> 

     </ScrollView> 
<!--for bottom bar --> 
     <RelativeLayout android:layout_height="50dp" 
      android:gravity="center" android:layout_width="match_parent" 
      android:id="@+id/linearLayout2" android:background="#ffffff"> 
      <Button ></Button> 
      <Button ></Button> 
      <Button ></Button> 
     </RelativeLayout> 

</LinearLayout> 
0

のLinearLayout内のすべてのものは、そのキーボードの上に、このような設計レイアウトに適合します:

<LinearLayout weightSum="X"> 

    <ScrollView ayout_weight="y" > 
    .... 
    ..... 
    </ScrollView> 

<Layout layout_wieght="z"> 
     <btn save />   <btn cancel /> 
</layout> 
<linearLayout> 
0

は以下のコードを試してみてください。その中のメインレイアウトは

です)1)scrollviewでは、多くのビューを持つレイアウトを追加できます。

2)「保存してキャンセル」するための2つのボタンがある別のレイアウト。ボタンバーとしてスタイルを追加します。 スクロールビューにウェイト= 1を追加しないでください。

下記のレイアウトを試してみてください。

<?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" > 

<ScrollView 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:layout_weight="1" 
android:scrollbars="horizontal|vertical" > 


</ScrollView> 

//上記のスクロールビューでは、他のビューのレイアウトを追加します。あなたは

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
style="@android:style/ButtonBar" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:gravity="center" 
android:orientation="horizontal" > 

<Button 
    android:id="@+id/browseAddBtn" 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:layout_marginRight="10dp" 
    android:layout_weight="1" 
    android:text="Add" /> 

<Button 
    android:id="@+id/browseViewBtn" 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:layout_marginRight="10dp" 
    android:layout_weight="1" 
    android:text="Back" /> 

<Button 
    android:id="@+id/browseReturnBtn" 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:text="Save" /> 
</LinearLayout> 
関連する問題