2011-06-09 8 views
2

私のインクルードを画面の最後に正確にする方法を教えてください。当時、彼はコンテンツの終わりに達しています。RelativeLayout、Include、layout_alignParentBottomは機能しません

<!-- language: lang-xml --> 
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="fill_parent"> 
    <ScrollView android:layout_width="fill_parent" 
     android:layout_height="fill_parent" android:background="#f6ba79" 
     android:orientation="vertical" android:id="@+id/layout"> 
     <LinearLayout android:id="@+id/linearLayout2" 
      android:orientation="vertical" android:layout_width="fill_parent" 
      android:layout_height="fill_parent" android:background="@drawable/preferences_background"> 
      <include android:id="@+id/include1" android:layout_width="fill_parent" 
       layout="@layout/top" android:layout_height="wrap_content"></include> 
      <LinearLayout android:layout_width="fill_parent" 
       android:gravity="center" android:id="@+id/linearLayout1" 
       android:layout_height="wrap_content"> 
       <LinearLayout android:orientation="vertical" 
        android:layout_width="270dp" android:id="@+id/body" 
        android:layout_height="wrap_content" android:focusableInTouchMode="true"> 
        <ImageView android:src="@drawable/preferences" 
         style="@style/Theme.Connector.ImageElement" android:layout_width="wrap_content" 
         android:id="@+id/title" android:layout_height="wrap_content"></ImageView> 
        <Spinner android:layout_width="fill_parent" 
         style="@style/Theme.Connector.WelcomeSpinner" 
         android:layout_weight="1" android:id="@+id/spinner_isp" 
         android:layout_height="wrap_content" /> 
        <EditText android:singleLine="true" android:hint="@string/txt_user" 
         android:layout_height="wrap_content" android:layout_width="fill_parent" 
         android:id="@+id/edit_user" style="@style/Theme.Connector.PreferencesInput" /> 
        <EditText android:singleLine="true" android:hint="@string/txt_password" 
         android:layout_height="wrap_content" android:layout_width="fill_parent" 
         android:id="@+id/edit_password" android:password="true" 
         style="@style/Theme.Connector.PreferencesInput" /> 
        <LinearLayout android:orientation="vertical" 
         android:layout_width="fill_parent" android:id="@+id/frm_action" 
         android:layout_height="fill_parent" android:baselineAligned="false"> 
         <Button android:text="@string/btn_save" 
          android:layout_weight="0" android:layout_width="130dp" 
          android:layout_height="wrap_content" style="@style/Theme.Connector.Button" 
          android:layout_gravity="center" android:id="@+id/btn_save"></Button> 
        </LinearLayout> 
       </LinearLayout> 
      </LinearLayout> 
     </LinearLayout> 
    </ScrollView> 
     <include android:id="@+id/include1" android:layout_width="fill_parent" 
      layout="@layout/menu" android:layout_height="wrap_content" android:layout_alignParentBottom="true"></include> 
</RelativeLayout> 

Device Screen Capture

答えて

4

問題は、あなたのScrollerViewは= "fill_parent" layout_heightを持っていることです。 RelativeLayoutはそのビューを空間全体に塗りつぶします。

AのLinearLayoutは、より良いあなたのケースで動作します:

<?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 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:background="#f6ba79" 
     android:orientation="vertical" 
     android:id="@+id/layout"> 

     ... 

    </ScrollView> 
    <include 
     android:id="@+id/include1" 
     android:layout_width="fill_parent" 
     layout="@layout/menu" 
     android:layout_height="wrap_content" /> 
</LinearLayout> 

ここで重要なのは、0dpからScrollerViewセットの高さと(実際にまたは任意の数)1に設定された重みを持つことです。 LinearLayoutはScrollerViewを引き伸ばしてビューを塗りつぶし、さらに下部に@layout/menuのためのスペースを確保します。

+0

ありがとうございました!あなたのソリューションはうまくいきます。 –

関連する問題