简体   繁体   中英

layout_weight is not working in scroll view

I am trying to use this code but its not working when i put layout weight.If i remove layout weight and enter height for image view,it works fine.

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

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

    <ImageView
        android:id="@+id/informative_image_view"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="3.7"
        android:scaleType="fitXY"></ImageView>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view_option_menu"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="6.3" />
</LinearLayout>
</ScrollView>

Actually you don't need scrollview. Remove it. And if you are using recyclerview inside scrollview then you need to specify height in dp of list to make it work properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM