2017-02-10 21 views
0

ここでは基本レイアウトがありますが、ScrollView内のLinearLayoutは親の高さと一致していません。子レイアウトの高さが親レイアウトと一致しません

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

    <Button 
    . 
    ./> 

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

     <LinearLayout 
      android:id = "@+id/layoutWeb" 
      android:layout_width = "match_parent" 
      android:layout_height = "match_parent" 
      android:orientation = "vertical"> 

      <ListView 
       android:id = "@+id/listWeb" 
       android:layout_width = "match_parent" 
       android:layout_height = "match_parent"> 

      </ListView> 

     </LinearLayout> 

    </ScrollView> 

</LinearLayout> 

IDEはwrap_parentに線形レイアウトの(ID = layoutWeb)高さを変更することを示唆しています。私は、下のスクリーンショットでリニアレイアウトを選択しているが、その高さは、親に Screenshot

+1

ListViewをScrollViewに入れないでください。最初のLinearLayoutにはパディングが含まれていますか? –

+0

私はそれがとてもばかげていることを実感しました。しかし、なぜそれは動作しませんか? –

+0

match_parentはScrollViewルートでは機能しません。また、新しいスクロールを別のスクロール(ListViewをScrollViewに挿入)する必要があります。 –

答えて

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


<LinearLayout 
    android:id="@+id/layoutWeb" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 
    <ListView 
      android:id="@+id/listWeb" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"/> 
</LinearLayout> 

このコードを試しに一致していません。あなたはscrollviewを取る必要はありませんlistviewのために。すでにスクロール可能

+0

ありがとうございます。分かりました –

関連する問題