我是Android超级新手-
我在屏幕上放了一个滚动视图,只是在里面放了一些文本。我之所以这样做,是因为在某些手机上,文本会从屏幕上消失。
我遇到的问题是,我放到页面上的滚动视图比它包含的内容要长--手机屏幕越窄,滚动视图就越长。
<?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's 14 Day Fat Furnace Workout Program! This is a detailed 14 Day Workout plan based on Fit Body Boot Camp'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>在这之后还有更多的社论文本,但这是它的要点。如果你看到什么傻事就告诉我。
发布于 2013-07-05 21:53:58
您的背景位于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>发布于 2013-04-03 06:08:46
我认为scrollview应该填充父视图,子视图包装内容,因为layout_height是视图在屏幕上的实际大小,滚动操作发生在视图内部
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
//...
android:layout_height="fill_parent"
//...
>编辑
正如dbalaouras指出的那样,最好使用"match_parent“而不是"fill_parent”,因为后者已被弃用。结果是一样的,只是名称被更改了,只是因为" fill“令人困惑,如果你设置它不会填充剩余的空间,而只是根据它的父级设置维度
https://stackoverflow.com/questions/15775286
复制相似问题