gpt4 book ai didi

Android ScrollView 太长

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:46:24 24 4
gpt4 key购买 nike

我是 Android 新手 -

我在屏幕上放置了一个 ScrollView ,只是在其中放置了一些文本。我这样做是因为在某些手机上,文本会从屏幕上消失。

我遇到的问题是我放到页面上的 ScrollView 比它包含的内容长——手机屏幕越窄, ScrollView 越长。

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true" >

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/app_background"
android:orientation="vertical"
android:padding="10dp" >

<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="20"
android:inputType="textMultiLine"
android:lineSpacingExtra="3dp"
android:text="Get ready to melt fat and burn calories with Fit Body Boot Camp&apos;s 14 Day Fat Furnace Workout Program! This is a detailed 14 Day Workout plan based on Fit Body Boot Camp&apos;s Unstoppable Fitness Formula that has been implemented in close to 300 boot camps worldwide by hundreds of thousands of clients who made the decision to lose weight and get healthier."
android:textColor="#FFF"
android:textColorLink="#FFF"
android:textSize="20sp" >
</EditText>

在这个之后还有一些编辑文本,但这是它的要点。如果您看到一些愚蠢的事情,请告诉我。

最佳答案

您的背景位于 ScrollView 中的线性布局中。如果将 ScrollView 放在另一个线性布局中,该布局是 ScrollView 的父级并包含背景,并从作为 ScrollView 子级的线性布局中删除背景,问题将得到解决。

它看起来像这样:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/app_background" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true" >

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp" >

<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="20"
android:inputType="textMultiLine"
android:lineSpacingExtra="3dp"
android:text="THE LONG TEXT YOU'VE TYPED"
android:textColor="#FFF"
android:textColorLink="#FFF"
android:textSize="20sp" >
</EditText>
</LinearLayout>
</ScrollView>
</LinearLayout>

关于Android ScrollView 太长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15775286/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com