尝试使我的整个布局可滚动

发布于 2024-12-26 01:59:26 字数 649 浏览 3 评论 0原文

我已经设计了布局,在较小的手机屏幕上并不是所有内容都可见,所以我想使其可滚动,有人可以帮助我解决这个问题吗?以下是我的布局的基本结构。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/allowanceroot"
    android:background="@drawable/background"
    >
    --TextView--
    --EditText--
    --TextView--
    --EditText--
    --TextView--
    --EditText--
</LinearLayout>

我是否只将 TextView 和 EditText 包含在 LinearLayout 中,然后将其包含在 ScrollView 中?还有什么我需要以编程方式做的事情吗?

I have designed my layout and on smaller phone screens not everything is visible, so I'd like to make it scrollable, could somebody help me with how to go about this? Below is the basic structure of my layout.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/allowanceroot"
    android:background="@drawable/background"
    >
    --TextView--
    --EditText--
    --TextView--
    --EditText--
    --TextView--
    --EditText--
</LinearLayout>

Do I just contain my TextViews and EditTexts in a LinearLayout, and then contain that in a ScrollView? Also is there anything I need to do programmatically?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半世蒼涼 2025-01-02 01:59:26

尝试将其包装在滚动视图中

https://stackoverflow.com/a/4202608/661079

您不需要做任何其他事情做

Try wrapping it in a scrollview

https://stackoverflow.com/a/4202608/661079

There is nothing else you need to do

靖瑶 2025-01-02 01:59:26

尝试这样

  <?xml version="1.0" encoding="utf-8"?>

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/scroller"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <TextView />
            <TextView />

        </LinearLayout>
    </ScrollView>

Try like this

  <?xml version="1.0" encoding="utf-8"?>

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/scroller"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <TextView />
            <TextView />

        </LinearLayout>
    </ScrollView>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文