1

こんにちは友達私はトラビスのビデオを見てアンドロイドを学び始めたところです。

彼は、画像スライダーを含むアプリを作成しました。私はすべてのステップを実行し、すべてが正常に機能しています。彼は使用しました

以下は私のXMLコードです。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

<ImageView
    android:id="@+id/IVDisplay"
    android:layout_width="wrap_content"
    android:layout_height="200dp"
    android:layout_gravity="center"
    android:src="@drawable/a"
     />

<Button
    android:id="@+id/setBG"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="@string/set_as_wallpaper" />

<HorizontalScrollView
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:fillViewport="true"
    android:scrollbars="horizontal|vertical" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/viewImage1"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:padding="15dp"
            android:src="@drawable/a" />

        <ImageView
            android:id="@+id/viewImage2"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:padding="15dp"
            android:src="@drawable/c" />

        <ImageView
            android:id="@+id/viewImage3"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:padding="15dp"
            android:src="@drawable/d" />

        <ImageView
            android:id="@+id/viewImage4"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:padding="15dp"
            android:src="@drawable/e" />

    </LinearLayout>
</HorizontalScrollView>
</LinearLayout>

画像は正しく表示されています...しかし、一度に表示できる画像は1つ半しかありません...他にも多くの画像があります...そこで、Horizo​​ntalScrollViewを使用して画像をスライドするスライダーを表示しています。

これは私が参照したビデオですhttp://www.youtube.com/watch?v=wp5sORsPopw

4

2 に答える 2

1

水平スクロールビュー幅を設定android:layout_width="200dp"したので、問題を解決するには、に置き換えますandroid:layout_width="wrap_content"

このような : -

<HorizontalScrollView
    android:layout_width="wrap_content"  <<SET it to wrap_content like
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:fillViewport="true"
    android:scrollbars="horizontal|vertical" >

水平スクロールビューでスクロールバーを表示します。

これを、水平スクロールビューを定義するレイアウトファイルに書き込みます。

android:fadeScrollbars="false" which is equivalent to ScrollView.setScrollbarFadingEnabled(false);

おっしゃるように問題ないと思います。その正常に動作します。エミュレータをチェックインしました。画像が横滑りします!!

于 2013-01-30T16:30:45.390 に答える
0

私はあなたの質問が普通に何であるかを理解していませんでした、しかし私はあなたがCleanあなたのプロジェクトをしなければならないことを理解したので、あなたのプロジェクトを選んできれいにするよりもProject(menuBarで)->に行ってください、それは助けになるはずです。Clean...

編集:ここに問題があります

    android:layout_width="200dp"
    android:layout_height="wrap_content"

このコードをこれに変更する必要があります

    android:layout_width="wrap_content"
    android:layout_height="200dp"

また、wrap_contentは、ビューがコンテンツを囲むのに十分な大きさである必要があることを意味します。したがって、これが問題になるはずです。

よろしく

于 2013-01-30T16:21:36.700 に答える