ScrollView局限:
滑动的只能是linearlayout,甚至整个布局都不能有RelativeLayout。这使得让人觉得ScrollView控件有点鸡肋。其实不然..........
linearlayout跟RelativeLayout布局在界面上来看只是空间间隔的区别,而在liearlayout中有一个<View/>能占用空间,单单用linearlayout要达到 RelativeLayout的效果,可以用<View/>来实现。在每个RelativeLayout 前加一个这样的VIEW
<View
android:id="@+id/view2"
android:layout_width="fill_parent"
android:layout_height="10sp"
android:layout_alignParentRight="true"
android:layout_below="@+id/clientinfo_headpicture"
android:background="@color/blue" />
<RelativeLayout
android:id="@+id/rel_attach"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
如果GRIDVIEW 滚动要自己重写下
public class MyGridView extends GridView{
public MyGridView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyGridView(Context context) {
super(context);
}
public MyGridView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(
Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
}
Listview
public class NoScrollListView extends ListView{
public NoScrollListView(Context context, AttributeSet attrs){
super(context, attrs);
}
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
int mExpandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, mExpandSpec);
}
}
共同学习,写下你的评论
评论加载中...
作者其他优质文章