从 TextView 中移除焦点

Remove focus from TextView

单击 ListView 项目,它会将我定向到第二个 activity。在这个 activity 中,我有三个 TextView、一个 seekbar 和一个 imageview。第三个 TextView 有很长的描述性文字。

问题是我去第二个的时候activity;它首先关注第三个 TextView。但是它应该集中在最顶部的TextView上。

我怎样才能专注于最顶层的 TextView 或确保 activity 从最顶层的 TextView 显示?

这是布局 xml 代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"

tools:context=".ReadingStoryActivity">

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/scrollView2">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:id="@+id/text_story_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_marginTop="10dp"
            android:fontFamily="sans-serif-condensed"
            android:gravity="center_horizontal"
            android:text="text_story_name"
            android:textAllCaps="true"
            android:textSize="18sp"
            android:textStyle="bold">

        </TextView>

        <TextView
            android:id="@+id/text_author_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="text_author_name"
            android:textAlignment="center"
            android:textSize="16sp"
            android:textStyle="bold|italic" />

        <Space
            android:layout_width="match_parent"
            android:layout_height="5dp"
            android:background="#000000"

            />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="match_parent"
            android:layout_height="5dp"
            android:background="#000000"
            app:srcCompat="?attr/actionModeSplitBackground" />

        <SeekBar
            android:id="@+id/seekBar_"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:thumb="@drawable/bar"
            android:layout_below="@+id/imageView2"

            android:layout_marginTop="1dp" />

        <TextView
            android:id="@+id/text_body_story"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"


            android:padding="10dp"
            android:text="text_body_story"
            android:textColorHighlight="#ffee04"
            android:textIsSelectable="true"
            android:textSize="14sp" />

    </LinearLayout>


</ScrollView>


<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/adView2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    ads:adSize="SMART_BANNER"
    ads:adUnitId="ca-app-pub-4xxxxxxxxxxxxxx" />

</RelativeLayout>

在这种情况下,系统最后聚焦 textview。可以在LinearLayout中加上android:focusableInTouchMode="true",这样就可以取焦点了。

  <ScrollView
        android:id="@+id/scrollView2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:focusableInTouchMode="true"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">