마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

새로운 액티비티 생성 시 이전 액티비티의 레이아웃을 보존한 상태로 생성가능한가요...?

0 추천

안녕하세요.

루트 액티비티에서 bottom에 탭과 비슷한 레이아웃을 달았는데요,

이 레이아웃에서 버튼을 클릭 시 새로운 액티비티를 생성하려고 합니다.

새로운 액티비티를 생성할 때, bottom의 레이아웃은 화면에서 고정된 상태이면서 위의 화면에 덮어씌여지는 화면을 구성하고 싶습니다.

 

Fragment를 사용하지 않은 이유는 bottom의 레이아웃이 필요할 때만 나타나서 인데요.

Fragment를 사용하여 전체 뷰를 구성하고 stack 관리를 하면서 레이아웃을 잡아야 할까요...?

좋은 해결책이 있다면 답변 부탁드립니다...ㅠ

 

현재 루트 액티비티의 xml코드입니다.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <kr.co.widget.ScrollViewExt
        android:id="@+id/activity_root_sv_root"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="none">


        <LinearLayout
            android:id="@+id/activity_root_ll_section_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">


            <RelativeLayout
                android:id="@+id/activity_root_rl_events_section"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <android.support.v4.view.ViewPager
                    android:id="@+id/activity_root_vp_event_section"
                    android:layout_width="match_parent"
                    android:layout_height="300dp" />

                <me.relex.circleindicator.CircleIndicator
                    android:id="@+id/activity_root_vp_indicator"
                    app:ci_width="10dp"
                    app:ci_height="10dp"
                    app:ci_margin="6dp"
                    app:ci_animator="@anim/indicator_animator"
                    app:ci_drawable="@drawable/white_radius"
                    android:layout_alignParentBottom="true"
                    android:layout_width="fill_parent"
                    android:layout_height="40dp" />

            </RelativeLayout>

            <LinearLayout
                android:id="@+id/activity_root_ll_products_section"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

            </LinearLayout>
        </LinearLayout>
    </kr.co.widget.ScrollViewExt>


    <ImageButton
        android:id="@+id/activity_root_btn_opendrawer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="15dip"
        android:layout_marginTop="15dip"
        android:layout_alignParentRight="true"
        android:src="@drawable/ic_drawer"
        android:background="@android:color/transparent"/>

    <include
        layout="@layout/layout_bottom_nav"
        android:id="@+id/activity_root_bottom_nav"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"/>

</RelativeLayout>

 

taejun (7,240 포인트) 님이 2015년 4월 29일 질문

1개의 답변

+1 추천
addContentView  ?
aucd29 (218,390 포인트) 님이 2015년 4월 29일 답변
답변감사드립니다.

답변 주신대로 addContentView를 하여서 하단 버튼 클릭 시 새로운 레이아웃을 오버레이 시켰는데요.

addContentView를 할 때, 루트 레이아웃을 보이지 않게 하면서(하지만 include한 레이아웃은 살아남고...) 오버레이 된 레이아웃만 보여줄 수 있는 방법이 있을까요...?
rootlayout 에 해당하는 view 를 invisible 하시면 되지 않을까요?
layout 만 toggle 형태라면 굳이 addContentView 가 아닌
root view 에 child view 를 add 한 뒤에 show / hide 시켜도 되구요
그렇다면,,,
지금 현재 addContentView 후 ScrollView를 GONE 시킨 상태입니다.
addContentView를 할 시 루트 레이아웃의 가장 밑단에 차일드로 생성되는 것 같은데,,,
코드 상에서 ImageButton과 include된 레이아웃 위에 생성이 됩니다... 이는 각각 addContentView를 할 시 LayoutParams를 이용해서 다시 셋팅을 해야하나요..?
RelativeLayout 에 id 를 부여하고 RelativeLayout 를 gone 시키세요
답변 감사드립니다... 현재 RelativeLayout 안에 ImageButton과 include 된 레이아웃은 그대로 가져가고 싶습니다... RelativeLayout을 GONE시키면 모두 사라져서 말이에요...ㅠ
imagebutton 을 포함한 layout 을 하나 만들고 그걸 양쪽에 모두 include 하세요..

아니면 activity_root_ll_section_container 에 삽입할 layout 을 addview 하고 toggle 하세요
...