2016-09-04 7 views
1

以下は、画面の下部にあるボタンに十分な大きさの小さな部分を除いて、画面全体を占めるスクロールビューを表示します。私がこれを実行すると、ボタン/レイアウトはまったく表示されません。私がスクロールビュー内に持っている他のビューで画面全体を占めるスクロールビューのみ。思考?スクロールビューの下の線画が表示されない

<LinearLayout android:layout_width="match_parent" 
android:layout_height="match_parent" 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
tools:context="com.th3ramr0d.armybodyfatcalculator.MainActivity" 
android:orientation="vertical"> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

    </ScrollView> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Button 1" 
     /> 


    </LinearLayout> 
</LinearLayout 
+0

このレイアウト作業のために仕事をしますが、私は私が依存のためにscrollviewの大きさを決定するために、デバイスをしたい、あなたのスクロールビュー – dex

+0

に定義されたのmaxHeightに必要その下のレイアウトのサイズそれは可能ですか? – th3ramr0d

+0

次に@Tiago Oliveiraの回答を – dex

答えて

1

これは、あなたが

<RelativeLayout android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    tools:context="com.th3ramr0d.armybodyfatcalculator.MainActivity" 
    xmlns:tools="http://schemas.android.com/tools" 
    > 
    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentTop="true" 
     android:layout_above="@+id/myButton"> 
    </ScrollView> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Button 1" 
     android:layout_alignParentBottom="true" 
     android:id="@+id/myButton" /> 
</RelativeLayout> 
+0

と考えてください。外部のLinearLayoutは冗長ですので、一番上の要素としてRelativeLayoutを持つだけで十分です。 – Egor

+0

@Egorアンドロイドは、ルートレイアウトとしてrelativelayoutを避けることを推奨します。これがパフォーマンスの問題につながるかどうかを知りたかっただけです。 – dex

+1

が更新されました.relativelayoutをrootとして使用したことがありませんでした –

関連する問題