2016-11-28 3 views
0

私は、スクロールビューとその下のボタンの2つの子を持つ相対ビューを持っています。これを行うには、このビューをコンテンツにラップしてもらいたい空きスペースを作らず、画面サイズを超えないようにしてください。 どうすればいいですか?誰でも助けてくれる?アンドロイドは、特定のサイズを超えてコンテンツをラップするようにビューを作成します。

ここは私の現在のレイアウトファイルで、動作しません。

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

    <ScrollView 
     android:id="@+id/content" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
       .... 
    </ScrollView> 
    <Button 
     android:id="@+id/action" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/content" 
     ... /> 
</RelativeLayout> 
+0

android:maxHeight = "その高さでのあなたの身長" –

+0

これは現在どのように見ていますか?あなたはスクリーンショットを添付することができます –

答えて

2

RelativeLayoutこのような可能性はありません。しかし、LinearLayoutがあります。ただ、設定LinearLayoutandroid:layout_weight1に、さんandroid:orientationverticalには、ScrollViewセット 'と動作するはず:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

    <ScrollView 
     android:id="@+id/content" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 
    </ScrollView> 

    <Button 
     android:id="@+id/action" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"/> 
</LinearLayout> 
+0

素晴らしい!おとこ。それは素晴らしい。 –

0

あなたはのLinearLayoutを使用してweight.Inそれは任意の解像度で超えないと、画面の大きた内容に応じて調整されますその方法に応じて両方のビューを調整する必要があります。

<LinearLayout 
    android:layout_width="match_parent" 
    android:orientation="vertical" 
    android:layout_height="match_parent"> 

    <ScrollView 
     android:fillViewPort="true" 
     android:id="@+id/content" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="4" 
    </ScrollView> 
    <Button 
     android:id="@+id/action" 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:layout_below="@id/content" 
     ... /> 
</LinearLayout> 
0

あなたはアクションボタンが下部に揃え確認する必要があり、そのスクロールビューは、そのボタンの上でなければなりません。このようにして、スクロールビューは常に画面に表示され、ボタンも表示されます。

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

     <Button 
      android:id="@+id/action" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      ... /> 
     <ScrollView 
      android:id="@+id/content" 
      android:layout_width="match_parent" 
      android:layout_above="@id/action" 
      android:layout_height="match_parent"> 
        .... 
     </ScrollView> 

    </RelativeLayout> 
+0

上記のように機能していない部分は画面が空です – hasan

関連する問題