1

実行時に ScrollView の高さを徐々に増やすプロセスはありますか。私の意図は、ScrollView 内にある画像を徐々に表示することです。そのため、ScrollView の高さを増やしたいと考えています。私の仕事をする方法はありますか?? 私のXmlFileの内容は次のとおりです。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/rootLayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="wrap_content"
        android:layout_height="80dp"
        android:scrollbars="none"
        android:layout_x="0dp"
        android:layout_y="0dp"
        android:fillViewport="true" >

        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >


    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="0dp"
        android:layout_y="0dp"
        android:src="@drawable/background" />
        </LinearLayout>

    </ScrollView>

    </LinearLayout>

私のコードは:

final Timer timer = new Timer();
    timer.scheduleAtFixedRate(new TimerTask() {
        public void run() {
          runOnUiThread(new Runnable()
            {
                public void run() {

                    secondCounter++;
                    yourNewHeight += 10;
                    // sv is object of scroll view
                    sv.getLayoutParams().height = yourNewHeight;

                    root.invalidate(); // root is rootview


                    if(secondCounter == 20){
                        timer.cancel();
                    }
                }
            });
        }
    }, delay, period);

これが私のスクリーンショットです:

ここに画像の説明を入力

ぼやけた画像はScrollviewにあり、ScrollViewの高さが増すにつれて、ぼやけた画像が徐々に表示されます。

4

2 に答える 2

0

私はあなたのコードを編集しました..

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rootLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="fill_parent"
    android:layout_height="80dp">

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width=" fill_parent"
        android:layout_height="wrap_content" >


<ImageView
    android:id="@+id/imageView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:src="@drawable/background" />
    </LinearLayout>

</ScrollView>

これをやったかどうか教えてください..わかりました..

于 2012-07-13T06:50:14.590 に答える
0

を使用しsetLayoutParams(..)て、幅と高さをプログラムで設定できます。maoの質問とその解決策を確認してください

于 2012-07-13T07:09:51.580 に答える