Can we use a ScrollView inside a LinearLayout?

后端 未结 1 506
陌清茗
陌清茗 2020-12-16 21:43

I need to design a GUI with content at the top of the screen that doesn\'t scroll, and content below the top part that does scroll. I thought about using a LinearLayout for

相关标签:
1条回答
  • 2020-12-16 22:23

    You can

    <LinearLayout
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical"
      >
    
      <!-- non-scrolling top pane -->
      <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        >
    
        <TextView
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:text="This text will not scroll"
          />
    
      </LinearLayout>
    
      <!-- scrolling bottom pane -->
      <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        >
    
        <LinearLayout
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          >
    
          <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="This text will scroll if it is long enough..."
            />
    
        </LinearLayout>
    
      </ScrollView>
    
    </LinearLayout>
    
    0 讨论(0)
提交回复
热议问题