首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安卓textView卷轴

问安卓textView卷轴
EN

Stack Overflow用户
提问于 2012-02-10 00:03:22
回答 2查看 1.6K关注 0票数 0

我一直在尝试开发一个android应用程序,其中包含一个可滚动的活动,在这个活动中,我有两个textView,我希望它们也可以滚动。

我的问题是,每当我触摸到textView内部时,卷轴就会出现,但主要的活动部分,即linearLayout直接强化焦点,而不再是textView滚动。

我现在使用的方式是为textView在我所做的xml文件中滚动设置。如果我继续举起手指,把它放回屏幕上,试图滚动textView,我可以移动一点点,但正如我所说,包含textView的布局捕获焦点,使我无法滚动textView。

我希望我能很好地解释我的问题。

请提出任何帮助的建议。

让我解释一下这个应用程序是如何构建的,第一部分是:主(第一个)活动是一个tabHost,我把它定义为可滚动的。

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" > 
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >   
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="422dp" >
</FrameLayout>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="63dp" >
</TabWidget>
</LinearLayout>
</ScrollView>
</TabHost>

我有问题的地方是这个活动

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/light_gray_color" 
android:layout_height="match_parent" 
android:layout_width="match_parent" 
android:weightSum="1" 
android:orientation="vertical"

android:baselineAligned="false">

<LinearLayout 
android:id="@+id/linearLayout3" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:layout_weight="0.04">

<TextView 
android:textAppearance="?android:attr/textAppearanceLarge" 
android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
android:textColor="@color/black_color" 
android:layout_gravity="center_horizontal" 
android:text="@string/display_label" 
android:id="@+id/display_label">
</TextView>

</LinearLayout>


<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.83"
android:baselineAligned="false"
android:orientation="horizontal" >


<ScrollView
android:id="@+id/english_scrollView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.03" >

<TextView
android:id="@+id/display_english_textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2px"
android:layout_marginRight="2px"
android:layout_weight="0.03"
android:background="@drawable/black_rectangle"
android:focusable="true"
android:paddingLeft="2px"
android:paddingRight="2px"
android:scrollbars="vertical"
android:textColor="@color/black_color" />

</ScrollView>


<ScrollView
android:id="@+id/translation_scrollView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.03" >

<TextView
android:id="@+id/display_translation_textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2px"
android:layout_marginRight="2px"
android:layout_weight="0.03"
android:background="@drawable/black_rectangle"
android:focusable="true"
android:paddingLeft="2px"
android:paddingRight="2px"
android:scrollbars="vertical"
android:textColor="@color/black_color" />

</ScrollView>
</LinearLayout>

</LinearLayout>
EN

回答 2

Stack Overflow用户

发布于 2012-02-10 02:17:28

我想您应该从第一个xml中删除<ScrollView>。

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >   
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="422dp" >
</FrameLayout>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="63dp" >
</TabWidget>
</LinearLayout>
</TabHost>
票数 0
EN

Stack Overflow用户

发布于 2012-02-10 08:03:31

我的理解是,您有一个垂直滚动活动,其中包含两个垂直滚动文本视图?如果是这样的话,你就不能这么做。这不仅是一个糟糕的设计选择,它的字面上不可能知道哪个视图的用户打算滚动时,他们进行滑动运动。您可以在垂直滚动视图中进行水平滚动,反之亦然。在水平滚动中不能有水平滚动,在垂直滚动中不能有垂直滚动。

我相信这是在2010年google io会议的列表视图演讲中提到的:http://www.youtube.com/watch?v=wDBM6wVEO70。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9220864

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档