<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>
這是我的xml文件。其中可惜的是簡單得多。我的目的是爲了提高動態滾動視圖的高度和圖像(這是滾動視圖)視圖將gradually.so顯示我怎麼能做到這一點,什麼是rootLayout這裏,我怎麼叫rootLayout從我的代碼?什麼是XML中的根佈局?
final Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
runOnUiThread(new Runnable()
{
public void run() {
secondCounter++;
yourNewHeight += 10;
sv.getLayoutParams().height = yourNewHeight;
LinearLayout root = (LinearLayout) findViewById(R.id.rootLayout);
root.invalidate();
Log.v("", "" +sv.getLayoutParams().height);
if(secondCounter == 20){
timer.cancel();
}
}
});
}
}, delay, period);
這是我在java文件中的代碼,但它不工作。夥計們,你能幫我解決.. !!!
請注意,'AbsoluteLayout'早已貶值,你應該使用的替代品。 – Trevor 2012-07-12 10:39:58
使用相對佈局相反,你不必增加gridview給它包裝內容,你必須動態添加圖像線性佈局,這將在scrollview – AkashG 2012-07-12 10:46:21
下謝謝.. :-)但我不能正確放置項目在XMl當我使用線性佈局。 – Amitabha 2012-07-12 10:58:21