Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android文本视图滚动_Android_Textview_Android Scrollview - Fatal编程技术网

Android文本视图滚动

Android文本视图滚动,android,textview,android-scrollview,Android,Textview,Android Scrollview,我一直在尝试开发一个android应用程序,其中包含一个可滚动的活动 在活动中,我有两个文本视图,我希望它们也可以滚动 我的问题是 每当我触摸文本视图内部时,滚动条就会出现,但主要活动部分(线性布局)会直接突出焦点,而不再是文本视图滚动条 我现在的方式是设置textView,以便在我已经完成的xml文件中滚动。 如果我一直抬起手指并将其放回屏幕上,尝试滚动textView,我可以移动一点,但正如我所说,包含textView的布局捕获了焦点,使我无法滚动textView 我希望我能很好地解释我的问

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

我的问题是 每当我触摸文本视图内部时,滚动条就会出现,但主要活动部分(线性布局)会直接突出焦点,而不再是文本视图滚动条

我现在的方式是设置textView,以便在我已经完成的xml文件中滚动。 如果我一直抬起手指并将其放回屏幕上,尝试滚动textView,我可以移动一点,但正如我所说,包含textView的布局捕获了焦点,使我无法滚动textView

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

请提供任何帮助的建议


让我先解释一下应用程序是如何构建的 第一部分是:主要(第一)活动是tabHost 我定义为可滚动的

<?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>

我遇到的问题是这项活动

<?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>

我想您应该从第一个xml中删除

<?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>

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


我相信在2010年谷歌io大会的listview演讲中提到了这一点:

你能添加你的代码吗,然后我们可以看到发生了什么,谢谢。好吧,谢谢你,但是如果我听从你的建议,那么应用程序中的所有活动都将无法滚动???嗯,您是否尝试在第二个xml而不是第一个xml中添加ScrollView?。。无论如何,结果可能是一样的。它可能是关于设置像可聚焦真假这样的东西,我知道的不多。对不起,我帮不了什么忙。等待另一个答案:)别担心。我试图将ScrollView放在那里,同时将ScrollView保留在第一个XML中,但这就是问题所在。我也尝试过使用focus做一些事情,比如getFocus(),但因为我在这方面非常在行,所以我认为这没什么用。无论如何,谢谢你:)