【问题标题】:background to scroll with Scrollview使用 Scrollview 滚动的背景
【发布时间】:2020-09-06 19:16:40
【问题描述】:

如何使背景沿视图或布局滚动?

这是我的布局

    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/body_information">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:paddingStart="60dp"
    android:paddingEnd="60dp">



</LinearLayout>

【问题讨论】:

    标签: java android xml layout scrollview


    【解决方案1】:

    通过使用 scrollView,您会导致子项(在本例中为 LinearLayout)在屏幕上移动,而不是由 ScrollView 本身移动。因此,要使图像随着 LinearLayout 移动,请在其上放置 background 属性。

    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="@drawable/body_information"
    android:paddingStart="60dp"
    android:paddingEnd="60dp">
    </LinearLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-19
      • 2022-11-08
      • 1970-01-01
      • 2014-06-15
      • 1970-01-01
      相关资源
      最近更新 更多