2017-12-15 37 views
-1

こんにちは私はScrollViewにLinearLayoutを持っています このLinearLayoutでは、いくつかのチェックボックスと ボタンが下部にあります。 垂直ビューでは正常ですが水平ビューで ボタンが消えます。ボタンが水平方向に消える

あなたはスクリーンショットにこの状況を見ることができます:もちろん

垂直ビュー

水平視野

をsrclolli doesntのヘルプ

をダウンngのこれが私のxml

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 

    > 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="80dp" 
    android:layout_marginLeft="10dp" 
    > 


    <CheckBox android:id="@+id/hotele" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Hotele" 
     android:textSize="18sp" 
     android:layout_margin="5dp" 
     android:checked="true" 
     /> 

    <!-- more checkboxs... --> 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     xmlns:android="http://schemas.android.com/apk/res/android"> 

     <Button 
      android:id="@+id/gotowe" 
      android:layout_width="160dp" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="30dp" 
      android:background="@color/colorPrimary" 
      android:padding="5dp" 
      android:text="Gotowe" 
      android:textColor="#fff" 
      android:textSize="16sp" 
      android:layout_centerInParent="true" 
      android:textAllCaps="false"/> 

    </RelativeLayout> 

</LinearLayout> 

</ScrollView> 
+0

スクロールしましたか? –

+1

もちろん馬鹿はありません:) – Agnes

+1

最初の線形レイアウトは、高さのためにwrap_contentである必要があります。 –

答えて

1

layout_height="wrap_content"であることを

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

を設定するようにしてくださいです。これにより、コンテンツの最後までスクロールできます。

+0

は役に立ちません。 – Agnes

+0

ボタンをラッピングしているRelativeLayoutに 'android:layout_marginBottom =" 80dp "'を設定してみます。 –

+0

OKこれは動作します、 – Agnes

0
<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 

    xmlns:android="http://schemas.android.com/apk/res/android"> 
<ScrollView android:layout_width="fill_parent" 
    android:layout_height="fill_parent> 

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_marginTop="80dp" 
     android:layout_marginLeft="10dp" 
     > 


     <CheckBox android:id="@+id/hotele" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Hotele" 
      android:textSize="18sp" 
      android:layout_margin="5dp" 
      android:checked="true" 
      /> 

     <!-- more checkboxs... --> 

     <RelativeLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      xmlns:android="http://schemas.android.com/apk/res/android"> 



     </RelativeLayout> 

    </LinearLayout> 

</ScrollView> 
    <Button 
     android:id="@+id/gotowe" 
     android:layout_width="160dp" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="30dp" 
     android:background="@color/colorPrimary" 
     android:padding="5dp" 
     android:text="Gotowe" 

     android:textColor="#fff" 
     android:textSize="16sp" 
     android:layout_centerInParent="true" 
     android:textAllCaps="false"/> 
</RelativeLayout> 
+0

これは画面の中央にボタンを作ってスクロールがそれ以上スクロールしません – Agnes

+0

ボタンの位置を相対的なレイアウトに変更します。 –

0

このコードを試してみてください。この

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 

    > 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_marginTop="80dp" 
    android:layout_marginLeft="10dp" 
    > 


    <CheckBox android:id="@+id/hotele" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Hotele" 
     android:textSize="18sp" 
     android:layout_margin="5dp" 
     android:checked="true" 
     /> 

    <!-- more checkboxs... --> 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     xmlns:android="http://schemas.android.com/apk/res/android"> 

     <Button 
      android:id="@+id/gotowe" 
      android:layout_width="160dp" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="30dp" 
      android:background="@color/colorPrimary" 
      android:padding="5dp" 
      android:text="Gotowe" 
      android:textColor="#fff" 
      android:textSize="16sp" 
      android:layout_centerInParent="true" 
      android:textAllCaps="false"/> 

    </RelativeLayout> 

</LinearLayout> 
</RelativeLayout> 
</ScrollView> 
0

をお試しください:チェックボックスのリストには、スクロール可能になり、ボタンが2つの場合に表示されます: (マージンとして選択するのはあなた次第ですあなたの余白の値)

enter image description here

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ScrollView 
     android:id="@+id/scrollable_holder" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/gotowe" 
     android:layout_marginLeft="10dp" 
     android:layout_marginTop="80dp" 
     android:isScrollContainer="true"> 

     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:orientation="vertical"> 

      <CheckBox 
       android:id="@+id/hotele" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:checked="true" 
       android:text="Hotele" 
       android:textSize="18sp" 
       /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:checked="true" 
       android:text="Hotele" 
       android:textSize="18sp" 
       /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:checked="true" 
       android:text="Hotele" 
       android:textSize="18sp" 
       /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:checked="true" 
       android:text="Hotele" 
       android:textSize="18sp" 
       /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:checked="true" 
       android:text="Hotele" 
       android:textSize="18sp" 
       /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:checked="true" 
       android:text="Hotele" 
       android:textSize="18sp" 
       /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:checked="true" 
       android:text="Hotele" 
       android:textSize="18sp" 
       /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:checked="true" 
       android:text="Hotele" 
       android:textSize="18sp" 
       /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:checked="true" 
       android:text="Hotele" 
       android:textSize="18sp" 
       /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:checked="true" 
       android:text="Hotele" 
       android:textSize="18sp" 
       /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:checked="true" 
       android:text="Hotele" 
       android:textSize="18sp" 
       /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:checked="true" 
       android:text="Hotele" 
       android:textSize="18sp" 
       /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:checked="true" 
       android:text="Hotele" 
       android:textSize="18sp" 
       /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:checked="true" 
       android:text="Hotele" 
       android:textSize="18sp" 
       /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:checked="true" 
       android:text="Hotele" 
       android:textSize="18sp" 
       /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:checked="true" 
       android:text="Hotele" 
       android:textSize="18sp" 
       /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:checked="true" 
       android:text="Hotele" 
       android:textSize="18sp" 
       /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:checked="true" 
       android:text="Hotele" 
       android:textSize="18sp" 
       /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="5dp" 
       android:checked="true" 
       android:text="Hotele" 
       android:textSize="18sp" 
       /> 
      <!-- more checkboxs... --> 
     </LinearLayout> 
    </ScrollView> 

    <Button 
     android:id="@+id/gotowe" 
     android:layout_width="160dp" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginBottom="10dp" 
     android:layout_marginTop="30dp" 
     android:background="@color/colorPrimary" 
     android:padding="5dp" 
     android:text="Gotowe" 
     android:textAllCaps="false" 
     android:textColor="#fff" 
     android:textSize="16sp"/> 

</RelativeLayout> 
+0

これは動作しますが、ボタンは左のものです – Agnes

+0

ボタンを左に配置したいですか? ボタンを左側に配置する場合は、==> remove ** android:layout_centerHorizo​​ntal = "true" **を追加し、** android:layout_alignParentLeft = "true" **を追加します。 –

1

私はわからないんだけどあなたの探しているものだが、これはあなたを助けるかもしれない

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_marginTop="80dp" 
     android:weightSum="10"> 

     <ScrollView 
      android:id="@+id/scrollView" 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:layout_marginBottom="10dp" 
      android:layout_weight="9.5"> 

      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="10dp" 
       android:orientation="vertical"> 

       <CheckBox 
        android:id="@+id/hotele" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_margin="5dp" 
        android:checked="true" 
        android:text="Hotele" 
        android:textSize="18sp" /> 
      </LinearLayout> 

     </ScrollView> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:layout_weight=".5"> 

      <Button 
       android:id="@+id/gotowe" 
       android:layout_width="160dp" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:layout_centerVertical="true" 
       android:layout_gravity="center" 
       android:background="@color/colorPrimary" 
       android:padding="5dp" 
       android:text="Gotowe" 
       android:textAllCaps="false" 
       android:textColor="#fff" 
       android:textSize="16sp" /> 
     </RelativeLayout> 
    </LinearLayout> 
0

現在のxmlファイルからちょっとした変更があります。 内側のLinearlayoutの余白をパディングに変更してみてください。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:paddingTop="80dp" 
     android:paddingLeft="10dp" 
     > 

私はこのように動作させることができました。

関連する問題