안드로이드 개발 질문/답변
(글 수 45,052)
안녕하세요.
xml 이용해서 화면을 꾸미고 있는데요. 하나의 레이아웃 위에 다른 레이아웃이 겹쳐져
보이려면 어떻게 해야 하나요?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background"
android:layout_gravity="center"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/main_title"
android:layout_gravity="center"
android:layout_marginTop="10dip"
android:textSize="24.5sp"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/photo_3"
android:scaleType="fitCenter"
android:layout_gravity="center"
/>
</LinearLayout></LinearLayout>
이렇게 하니까 텍스트 아래에 이미지가 뿌려져 버리는데요. xml에서 정의하는 것만으로는 안되는건지..
레이아웃과 그 속성들에 대해 잘 이해하기 위해 참고할 수 있는 것도 좀 알려주시면 감사하겠습니다.
헷갈리고 어렵네요ㅠㅠ
xml 이용해서 화면을 꾸미고 있는데요. 하나의 레이아웃 위에 다른 레이아웃이 겹쳐져
보이려면 어떻게 해야 하나요?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background"
android:layout_gravity="center"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/main_title"
android:layout_gravity="center"
android:layout_marginTop="10dip"
android:textSize="24.5sp"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/photo_3"
android:scaleType="fitCenter"
android:layout_gravity="center"
/>
</LinearLayout></LinearLayout>
이렇게 하니까 텍스트 아래에 이미지가 뿌려져 버리는데요. xml에서 정의하는 것만으로는 안되는건지..
레이아웃과 그 속성들에 대해 잘 이해하기 위해 참고할 수 있는 것도 좀 알려주시면 감사하겠습니다.
헷갈리고 어렵네요ㅠㅠ
2009.10.07 19:25:54
회색님, 답변 감사합니다. 기다리는 동안 RelativeLayout으로 구성해서
텍스트가 이미지 위에 뿌려지도록 했는데요. 좀 이상한 게 세로 이미지를
뿌려놓고 에뮬에서 ctrl+f11로 모드 전환하면 어플이 죽습니다. 죽은 다음
죽었던 모드 그대로 놓고 다시 어플 실행하면 이미지랑 텍스트 떠요. -_-;
LogCat보니까, 이렇게 나오는데..
10-07 10:03:51.871: ERROR/dalvikvm-heap(785): 9830400-byte external allocation too large for this process.
10-07 10:03:51.871: DEBUG/StatusBar(584): updateResources
10-07 10:03:51.912: ERROR/(785): VM won't let us allocate 9830400 bytes
10-07 10:03:51.922: DEBUG/skia(785): --- decoder->decode returned false
10-07 10:03:51.941: DEBUG/AndroidRuntime(785): Shutting down VM
10-07 10:03:51.951: WARN/dalvikvm(785): threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
10-07 10:03:51.961: ERROR/AndroidRuntime(785): Uncaught handler: thread main exiting due to uncaught exception
10-07 10:03:52.001: DEBUG/StatusBar(584): updateResources
10-07 10:03:52.032: ERROR/AndroidRuntime(785): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.example.aisa/org.example.aisa.AISA}: android.view.InflateException: Binary XML file line #8: Error inflating class java.lang.reflect.Constructor
10-07 10:03:52.032: ERROR/AndroidRuntime(785): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
10-07 10:03:52.032: ERROR/AndroidRuntime(785): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
혹시 무엇 때문인지 알 수 있을까요? 답답하네요ㅠㅠ
텍스트가 이미지 위에 뿌려지도록 했는데요. 좀 이상한 게 세로 이미지를
뿌려놓고 에뮬에서 ctrl+f11로 모드 전환하면 어플이 죽습니다. 죽은 다음
죽었던 모드 그대로 놓고 다시 어플 실행하면 이미지랑 텍스트 떠요. -_-;
LogCat보니까, 이렇게 나오는데..
10-07 10:03:51.871: ERROR/dalvikvm-heap(785): 9830400-byte external allocation too large for this process.
10-07 10:03:51.871: DEBUG/StatusBar(584): updateResources
10-07 10:03:51.912: ERROR/(785): VM won't let us allocate 9830400 bytes
10-07 10:03:51.922: DEBUG/skia(785): --- decoder->decode returned false
10-07 10:03:51.941: DEBUG/AndroidRuntime(785): Shutting down VM
10-07 10:03:51.951: WARN/dalvikvm(785): threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
10-07 10:03:51.961: ERROR/AndroidRuntime(785): Uncaught handler: thread main exiting due to uncaught exception
10-07 10:03:52.001: DEBUG/StatusBar(584): updateResources
10-07 10:03:52.032: ERROR/AndroidRuntime(785): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.example.aisa/org.example.aisa.AISA}: android.view.InflateException: Binary XML file line #8: Error inflating class java.lang.reflect.Constructor
10-07 10:03:52.032: ERROR/AndroidRuntime(785): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
10-07 10:03:52.032: ERROR/AndroidRuntime(785): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
혹시 무엇 때문인지 알 수 있을까요? 답답하네요ㅠㅠ