简体   繁体   中英

Scroll a TextView out the screen

I have a bit of a predicament.

My Layout is currently this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="@color/white"
              android:orientation="vertical">


  <android.support.v4.widget.NestedScrollView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:isScrollContainer="true">

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

      <TextView
          android:id="@+id/item_shipping_shipping_description"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_gravity="start|left"
          android:padding="@dimen/margin_16"/>


      <View
          android:id="@+id/line43"
          android:layout_width="match_parent"
          android:layout_height="@dimen/line_height"
          android:background="@color/light_gray"/>
    </LinearLayout>

  </android.support.v4.widget.NestedScrollView>

  <android.support.v7.widget.RecyclerView
      android:id="@+id/item_shipping_fragment_recyclerview"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="@color/white"
      android:isScrollContainer="true"/>
</LinearLayout>

The TextView is dynamic content set by the server and it can be really long sometimes.

The problem I am having is the TextView can take up the whole screen. This XML is a fragment that is in a TabLayout with a collapsable toolbar. So when I scroll the content I would like the TextView to scroll out the screen, if this is possible. I tried to embed the Textview in a scrollView but this doesn't work as you see about?

Got any ideas how I can still have the CollapsableToolbar collapse as well as scroll the Textview out the screen to reveal the RecyclerView?

Thank you

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="@color/white"
              android:orientation="vertical">




    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
 <android.support.v4.widget.NestedScrollView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:isScrollContainer="true">
      <TextView
          android:id="@+id/item_shipping_shipping_description"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_gravity="start|left"
          android:padding="@dimen/margin_16"/>
</android.support.v4.widget.NestedScrollView>

      <View
          android:id="@+id/line43"
          android:layout_width="match_parent"
          android:layout_height="@dimen/line_height"
          android:background="@color/light_gray"/>
    </LinearLayout>



  <android.support.v7.widget.RecyclerView
      android:id="@+id/item_shipping_fragment_recyclerview"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="@color/white"
      android:isScrollContainer="true"/>
</LinearLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM