您的位置:首页 > 其它

ScrollView与ListView的焦点问题,互相滑动互不影响

2016-04-15 09:46 309 查看
//布局
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${relativePackage}.${activityClass}"
android:id="@+id/scrollView" >

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<com.example.test_listview.MyListView
android:id="@+id/mylist"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
></com.example.test_listview.MyListView>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="你猜猜"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="你猜猜"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="你猜猜"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="你猜猜"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="你猜猜"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="你猜猜"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="你猜猜"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="你猜猜"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="你猜猜"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="你猜猜"/>
</LinearLayout>
</ScrollView>


//代码
ScrollView  scrollView=(ScrollView) findViewById(R.id.scrollView);
listview.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
if(event.getAction()==MotionEvent.ACTION_UP){
scrollView.requestDisallowInterceptTouchEvent(false);
}else{
scrollView.requestDisallowInterceptTouchEvent(true);
}
return false;
}
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: