我在滚动ListView里面遇到麻烦ScrollView.我有一个Activity在顶部有一些EditTexts,然后是一个带有两个选项卡的选项卡主机,每个选项卡都有一个ListView.当EditText视图聚焦时,软键盘出现,因为我有一个ScrollView,内容是可滚动的.但问题出现在ListViews中有更多项目(选项卡中的项目),即使有更多项目,我也无法滚动ListView.
以下是布局XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="?backgroundImage"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
android:layout_margin="10dip"
android:id="@+id/buttons">
<Button
android:text="Save"
android:layout_margin="2dip"
android:textSize="20dip"
android:id="@+id/btnSaveorUpdate"
android:layout_height="wrap_content"
android:layout_width="145dip"></Button>
<Button
android:text="Cancel"
android:layout_margin="2dip"
android:textSize="20dip"
android:id="@+id/btnCancelorDelete"
android:layout_height="wrap_content"
android:layout_width="145dip"></Button>
</LinearLayout>
<ScrollView
android:layout_above="@id/buttons"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:layout_margin="10dip">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="10dip">
<TextView
android:text="Bill details"
android:textColor="?textColorDark"
android:layout_alignParentTop="true"
android:id="@+id/txtEnterDetails"
android:textSize="25dip"
android:textStyle="bold"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_marginBottom="2dip"></TextView>
<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="0dip"
android:layout_height="0dip" />
<EditText
android:layout_width="fill_parent"
android:hint="Enter data"
android:inputType="numberDecimal"
android:id="@+id/txtSample"
android:textSize="@dimen/editText"
android:layout_height="@dimen/editTextHeight"
android:text=""></EditText>
<EditText
android:layout_width="fill_parent"
android:id="@+id/txtDescription"
android:hint="Enter description"
android:textSize="@dimen/editText" …Run Code Online (Sandbox Code Playgroud) 我正在尝试将Google地图放在滚动视图中,以便用户可以向下滚动其他内容以查看地图.问题是这个滚动视图占用了所有垂直触摸事件,因此地图的UI体验变得非常奇怪.
我知道在谷歌地图的V1中,您可以覆盖onTouch或setOnTouchListener以在MotionEvent.ACTION_DOWN上调用requestDisallowInterceptTouchEvent.我试图用V2实现类似的技巧无济于事.
到目前为止,我尝试过:
这些都没有解决滚动问题.我在这里错过了什么吗?如果有人在滚动视图中有一个地图的工作示例,请您分享代码示例吗?
我有一个水平滚动视图,其中包含视图组的层次结构,然后最终是一个谷歌地图.我的问题是HSV正在捕捉对地图意味着的左右拖动.我试过了
hsv.requestDisallowInterceptTouchEvent(true);
Run Code Online (Sandbox Code Playgroud)
乃至
mapView.getParent().requestDisallowInterceptTouchEvent(true);
Run Code Online (Sandbox Code Playgroud)
但无济于事.我有什么问题吗?或者你能建议另一个解决方案?
我认为这应该是我原来的问题:如何在ScrollView中实现Mapview中发布的解决方案.具体来说,我在哪里放置代码?
我在NestedScroollView内的MapView有问题。我的Google地图显示正确,但是,当我尝试滚动地图时,它不起作用。我不知道该怎么解决。谁能帮我?谢谢!
那是我的代码:Dog_view.xml
...
<android.support.v4.widget.NestedScrollView
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/nestedScroll"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<include layout="@layout/dog_view_layout"
android:layout_height="match_parent"
android:layout_width="match_parent"/>
</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)
dog_view_layout.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:background="#000"
android:layout_height="wrap_content"
android:paddingTop="20dp">
<com.google.android.gms.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
狗片段
...
MapView mMapView;
private GoogleMap googleMap;
public DogFragment(){
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.dog_view, container, false);
this.dog = getArguments().getParcelable("data");
mMapView = (MapView) rootView.findViewById(R.id.mapView);
mMapView.onCreate(savedInstanceState);
mMapView.onResume(); // needed to get the map to display immediately
try {
MapsInitializer.initialize(getActivity().getApplicationContext());
} catch (Exception e) {
e.printStackTrace(); …Run Code Online (Sandbox Code Playgroud)