2

下部レイアウトに必要なスペースを除いて、画面全体を上部レイアウトで埋める方法にこだわっています。必要に応じてレイアウトを配置するために相対レイアウトを使用していますが、トップ ビューがボトム ビューに必要なスペースを除いてすべてのスペースを占有するようにします (トップ ビューの高さはユーザー入力に応じて変化します)。以下のxmlを参照してください。現在、私のトップビューは、スクロールビュー内のリニアレイアウトが必要とするスペース + myTopButton が占めるスペースだけを占有します。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"
        android:background="@drawable/bg"
        android:paddingBottom="10dip"
        android:focusable="true"
        android:focusableInTouchMode="true">
   <RelativeLayout android:id="@+id/topLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="80dip"
        android:layout_alignParentTop="true">
     <ScrollView android:id="@+id/myscroll"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginBottom="65dip"
        android:paddingRight="2dip"
        android:paddingLeft="6dip"
        android:fillViewport="true">
        <LinearLayout style="@style/LinearLayoutInner"
        android:orientation="vertical">
        </LinearLayout> 
    </ScrollView>
    <LinearLayout android:orientation="horizontal"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true">
            <Button android:id="@+id/search"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
                android:layout_marginBottom="10dip"
                android:text="@string/search_viewdoses"/>
    </LinearLayout>
   </RelativeLayout>
   <RelativeLayout android:id="@+id/bottomLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="-60dip"
        android:layout_alignParentBottom="true">
            <TextView android:id="@+id/myText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:text="@string/mytext"></TextView>
            <EditText android:id="@+id/myEdit" 
                android:layout_width="80dip"
                android:layout_height="50dip"
            android:layout_alignParentBottom="true"
            android:layout_toRightOf="@+id/myText"
            android:singleLine="true"
            android:inputType="numberDecimal"></EditText>
            <Button android:id="@+id/save"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:layout_marginBottom="10dip"
                android:text="@string/mybuttontext"/>
    </RelativeLayout>
</RelativeLayout>

今すぐスクリーン:ここに画像の説明を入力

募集中のスクリーン:ここに画像の説明を入力

4

3 に答える 3

4

から下マージンを削除してtopLayout追加android:layout_above="@+d/bottomLayout"するだけです。ただし、xmlでbottomLayoutbeforeを定義する必要があります。topLayoutから上部マージンも削除する必要があると思いますbottomLayout

実際の scrollView とボタンについても同様です。

于 2012-06-17T19:29:03.313 に答える
1

レイアウトタグ内

   <RelativeLayout android:id="@+id/topLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="80dip"
    android:layout_alignParentTop="true">

取り外すだけandroid:layout_marginBottom="80dip"で準備完了です。それは、トップセクションの下部に醜い、不要なスペースを生み出すものです.

于 2013-10-07T06:37:15.227 に答える
1

android:layout_weight="1"ScrollViewをつけてみてください。

于 2012-06-17T19:24:38.593 に答える