RecycleView 出现的不显示或显示不全。
1.<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.v7.widget.RecyclerView android:id="@+id/mrc_protocols" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/mdp_10" android:layout_marginRight="@dimen/mdp_12" android:divider="@null" android:scrollbars="none" /> </RelativeLayout>
ScrollView中嵌套RecycleView滑动出现卡顿
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false) { @Override public boolean canScrollVertically() { return false; } }; //初始化视图 mrcProtocols.setLayoutManager(linearLayoutManager);
自动滚动到中间
ScrollView顶部子控件加下面这2个属性
android:focusable="true"
android:focusableInTouchMode="true"
他就不会自动滚动到中间了
<ScrollView android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:focusable="true" android:focusableInTouchMode="true" android:text="顶部控件" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="一堆控件" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="两堆控件" /> </LinearLayout> </ScrollView>
布局不能撑满全屏
Android 使用ScrollView属性fillViewport解决android布局不能撑满全屏。
使用了ScrollView 嵌套 LinearLayout时,在大屏幕手机如三星note3手机上下面会留白,问题的解决办法是在第一层LinearLayout里面嵌套多个LinearLayout,最重要的是将ScrollView中android:fillViewport设置为true。
当ScrollView里的元素想填满ScrollView时,使用”fill_parent”是不管用的,必需为ScrollView设置:android:fillViewport=”true”。
当ScrollView没有fillVeewport=“true”时, 里面的元素(比如LinearLayout)会按照wrap_content来计算(不论它是否设了”fill_parent”),而如果LinearLayout的元素设置了fill_parent,那么也是不管用的,
因为LinearLayout依赖里面的元素,而里面的元素又依赖LinearLayout,这样自相矛盾.所以里面元素设置了fill_parent,也会当做wrap_content来计算。