我一直在尝试开发一个 android 应用程序,其中包含一个可滚动的活动,并且在活动内部,我有 2 个 textView,我希望它们也可以滚动。
我的问题是,每当我在 textView 内部触摸时,滚动就会显示出来,但作为 linearLayout 的主要活动部分直接控制焦点,而不再是 textView 滚动
我现在拥有的方式是设置 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>