是否有任何过程在运行时逐渐增加ScrollView的高度。我的目的是逐步显示ScrollView中的图像,所以我想增加ScrollView的高度。有什么办法可以做我的工作吗?请帮我我XMLFILE的out.Content是:如何在ScrollView中逐渐显示图像?
<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的高度增加了模糊的图像逐渐显示。
您是否以编程方式在图像上添加多于? – AkashG 2012-07-13 06:53:51
没有。只有一个图像已经在scrollView中使用。 – Amitabha 2012-07-13 06:59:23
请向我清楚你想要显示什么。如果只有一个图像,而不是为什么你在scrollview中添加? – AkashG 2012-07-13 07:02:04