<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 파일입니다.이 파일은 매우 간단합니다. 내 의도는 스크롤보기의 높이를 동적으로 높이고 이미지 (스크롤보기와 함께 있음)보기가 점차적으로 표시됩니다. 그래서 어떻게 할 수 있습니까? 여기서 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);
이것은 자바 파일의 코드입니다.하지만 작동하지 않습니다. 너희들은 나를 도와 줄 수있어 .. !!!
AbsoluteLayout' 긴 감가 상각'주의하시기 바랍니다 사용하지 권하고 싶습니다 당신이 대안을 사용해야합니다. – Trevor
Relative layout 대신에 gridview를 늘려 콘텐츠를 줄이지 않아도됩니다. 스크롤 뷰 아래에 선형 레이아웃으로 이미지를 동적으로 추가해야합니다. – AkashG
고맙습니다. :-)하지만 XMl에 제대로 배치 할 수 없습니다. 선형 레이아웃을 사용할 때. – Amitabha