4

私は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&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>

この後もいくつかの編集テキストがありますが、これがその要点です。ばかげたことを見たら教えてください。

4

2 に答える 2

1

layout_height はビューが実際に画面上に持つサイズであるため、スクロールビューは親を埋め、子ビューはコンテンツをラップする必要があると思います。スクロールはビュー内で発生します

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    //...
    android:layout_height="fill_parent"
    //...
>

後者は推奨されていないため、「 fill_parent

」の代わりに「match_parent」を使用することをお勧めします。結果は同じです。「塗りつぶし」が紛らわしいという理由だけで名前が変更されました。残りのスペースを塗りつぶさず、親に従って寸法を設定するだけであると設定した場合

于 2013-04-02T22:08:46.133 に答える