実行時に 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の高さが増すにつれて、ぼやけた画像が徐々に表示されます。