---
title: "2014.06.04 ——— android ViewPager和GridView冲突"
author: "lipeng88213"
date: "2014-06-04T10:26:53Z"
tags: []
categories: ["移动开发"]
slug: "2014-06-04-android-viewpager-gridview"
draft: false
lastmod: "2014-06-04T10:26:53Z"
id: 2075745
url: "https://trylovecatch.iteye.com/blog/2075745"
---

2014.06.04 ——— android ViewPager和GridView冲突
参考：<http://stackoverflow.com/questions/15470755/textview-inside-viewpager-intercepts-touch-events>


我的ViewPager里面包含了三个字fragment，其中一个是view是gridview，里面展示了一些文本，item的view如下：

<
```java
?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="wrap_content"
    android:descendantFocusability="blocksDescendants"
    android:gravity="center" >
    

    <TextView
        android:id="@+id/tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:singleLine="true"
        android:gravity="center"
        android:textSize="16sp"
        android:textStyle="bold"
        android:textColor="#000000" />

</RelativeLayout>
```




这个时候，ViewPager左右滑动总是很不灵敏，解决方法：


```java
android:singleLine="true"
修改为
android:maxLines="1"
```