我有一个LinearLayout并在其中动态创建元素。如果它的高度大于屏幕高度的0.8,我需要使它滚动。我试图这样做。我的错误在哪里?RelativeLayout中的ScrollView不起作用
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:id="@+id/layoutContainer" android:orientation="vertical"
android:baselineAligned="false" android:weightSum="1">
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:scrollbars="vertical"
android:layout_weight="0.85" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:id="@+id/alarmsLayout" android:orientation="vertical"
android:layout_marginTop="70dp" >
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.15">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/addAlarmBtn"
android:src="@drawable/time"
android:layout_marginBottom="15dp" />
</LinearLayout>
</LinearLayout>
你相对布局权重1不0.8,也改变了滚动高度WRAP_CONTENT。也没有父母的布局。像weight attr一样,你应该使用LinearLayout作为父Layout的父代 –
的线性布局?如果是这样,你设定的weightSum是多少? –
只在这个滚动视图上设置监听器像这样 [onTouchlistener](http://stackoverflow.com/questions/34916506/animated-expandablelistview-in-scrollview/34916626#34916626) – pratik