scrollview 设置paddingTop后,滑动scrollview时,内容不能显示完全,会被padding给遮挡住。
解决: 设置android:clipToPadding = false;<ScrollView android:id="@+id/scrollView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_paddingTop="280dp" android:clipToPadding="false" </ScrollView>
使用DrawerLayout时,若显示的主区域内容包含scrollview时而抽屉的内容区域没有listview或者scrollview,在抽屉打开后,在抽屉上下滑动时,会将上下滑动事件传递给主区域scrollview导致scrollview会上下滑动,这显然不是我们所期望的。解决方法是将抽屉内容包裹在一个scrollview中,这样就不会滑动主区域的scrollview了。
<android.support.v4.widget.DrawerLayout ... ... > <!--主区域内容--> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.Toolbar android:id="@+id/app_bar" android:layout_width="match_parent" android:layout_height="?actionBarSize" app:contentInsetStart="12dp" app:layout_collapseMode="pin" /> <ScrollView android:id="@+id/scrollView" android:layout_below="@id/app_bar" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:id="@+id/scroll_content" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> </LinearLayout> </ScrollView> </RelativeLayout> <!--抽屉的内容--> <ScrollView android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="end" android:background="@color/colorTranslucence"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:scaleType="centerInside" android:src="@drawable/ic_login_poster"/> </RelativeLayout> </ScrollView> </android.support.v4.widget.DrawerLayout>
Android散打之ScrollView
最新推荐文章于 2024-01-09 10:04:32 发布