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

Activity를 팝업창으로 띄울 수 있게 하려고 합니다.

0 추천

해당 액티비티를 android:theme="@android:style/Theme.Dialog"로 바꿔줬고 따로 팝업 xml을 만들어서 그 창을 

setContentView(R.layout.activity_popup) 하게 했습니다. 근데 앱을 실행시키면 아래같이 화면이 줄어들었다가 커집니다.

        

한번에 오른쪽 화면 같이 되게 하고싶은데 프로그래스바 때문인지 ㅠㅠ 저렇게 되는 원인을 못찾겠어요.

아예 프로그래스바를 빼버리고 바로 레이아웃을 띄우려고하면 중앙에 작게 까만 정사각형 모양이 뜬 다음에

화면이 커지면서?? 레이아웃이 뜨고요.... 어찌해야될까요  일단 소스 올려봅니다.

xml 파일이고 프로그래스바만 올려봅니다.
     
<RelativeLayout
        android:id="@+id/detailProgressLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone"
        android:background="@drawable/app_background">
        <ProgressBar
            style="?android:attr/progressBarStyleLarge"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="158dp" />
    </RelativeLayout>
</LinearLayout>
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_popup);
    
    Intent intent = getIntent();
    PoNo = intent.getStringExtra("PoNo");
     
    detailProgressLayout = (RelativeLayout) findViewById(R.id.detailProgressLayout);
    detailMainLayout = (LinearLayout) findViewById(R.id.detailMainLayout);
    tvDispatchNo = (TextView) findViewById(R.id.tvDispatchNo);
    tvPoNo = (TextView) findViewById(R.id.tvPoNo);
    tvFromCenter = (TextView) findViewById(R.id.tvFromCenter);
    tvFromAddress = (TextView) findViewById(R.id.tvFromAddress);
    tvFromEmployee = (TextView) findViewById(R.id.tvFromEmployee);
    tvFromTelNo = (TextView) findViewById(R.id.tvFromTelNo);
    tvToCenter = (TextView) findViewById(R.id.tvToCenter);
    tvToAddress = (TextView) findViewById(R.id.tvToAddress);
    tvToEmployee = (TextView) findViewById(R.id.tvToEmployee);
    tvToTelNo = (TextView) findViewById(R.id.tvToTelNo);
     
    RequestParams params = new RequestParams();
    params.put("poNo",  PoNo);
    detailMainLayout.setVisibility(View.GONE);
    detailProgressLayout.setVisibility(View.VISIBLE);
    HttpClient.get("common/selectDispatchDetail.cmd", params, new AsyncHttpResponseHandler()
    {
        public void onSuccess(String response)
        {
            try
            {
                JSONArray list = new JSONArray(response.toString());
                JSONObject obj = (JSONObject) list.get(0);
                tvDispatchNo.setText(obj.getString("DispatchNo"));
                tvPoNo.setText(obj.getString("PoNo"));
                tvFromCenter.setText(obj.getString("FromCenter"));
                tvFromAddress.setText(obj.getString("FromAddress"));
                tvFromEmployee.setText(obj.getString("FromEmployee"));
                tvFromTelNo.setText(obj.getString("FromTelNo"));
                tvToCenter.setText(obj.getString("ToCenter"));
                tvToAddress.setText(obj.getString("ToAddress"));
                tvToEmployee.setText(obj.getString("ToEmployee"));
                tvToTelNo.setText(obj.getString("ToTelNo"));
                detailProgressLayout.setVisibility(View.GONE);
                detailMainLayout.setVisibility(View.VISIBLE);
            }
            catch (JSONException e) 
            {
                throw new RuntimeException(e);
            
        }
    });
}
 
public void onDestroy()
{
    super.onDestroy();
}

 

BMS (520 포인트) 님이 2014년 8월 1일 질문
BMS님이 2014년 8월 1일 수정

1개의 답변

0 추천
 
채택된 답변

Theme.Transparent를 사용해보세요 :)

develog (560 포인트) 님이 2014년 8월 1일 답변
BMS님이 2014년 8월 4일 채택됨
엇 근데 ㅠㅠ 레이아웃이 가운데로 안가네요... 레이아웃 자체를 가운데로 놓을 방법이 있을까요? 위에 자꾸 붙어서 보기가 안좋네요 흑흑
테마를 dialog로 하면 자동으로 가운데로 갔던거 같아요 크기도 작아지고...
Theme.Translucent 였군요;
음.. 저의 경우는 필요한 레이아웃을 RelativeLayout으로 감싸고
RelativeLayout에 android:layout_centerInParent속성을 true로 줬습니다.

아래 링크 참조하셔도 좋을듯요.
http://mydevromance.tistory.com/22
<RelativeLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content">
   
    <LinearLayout
        android:id="@+id/detailMainLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:background="#d9d9d9"
        android:layout_centerInParent="true"
        android:orientation="vertical" >

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="110dp"
            android:background="@drawable/blank_background">

            <TextView
                android:id="@+id/Trans_icon"
                android:layout_width="20dp"
                android:layout_height="20dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="16dp"
                android:background="@drawable/layout_icon"
                android:text="" />

랠러티브 레이아웃이 제일 바깥쪽 리니어 레이아웃 다음꺼고 그 안에 리니어 레이아웃이 컨텐츠들을 감싸고있어요. 위에 같이 속성값을 줬는데 자꾸 위로 붙네요 ㅠㅠ dp값을줘서 맞춰버리면 해상도가 안맞을텐데... 속성 저렇게 주는게 맞나요??
...