이 블로그 검색

2011년 7월 10일 일요일

다이알로그와 같은 액티비티 만들기

이렇게 액티비티를 메니페스트나 코드에서(둘 중에 하나만 하면 됨) 설정을 해 주면 마치 다이알로그 창과 같이 테두리가 없이 투명하게 액티비티를 만들 수 있다.

<메니페스트에서>
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"

<코드에서>
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

물론, layout 파일(xml)을 만들 때,
당연히 팝업 효과가 나오게 할려면 보이려는 부분은  background를 주고 주변은 alpha 값을 주어서 투명 처리하게 해야 된다.

알파 값은 간단히 xml에서 줄려면 background 에서 #칼라 값을 주면 된다.
원래 칼라 값이 8자리인데, 앞의 2자리가 알파값이다.
예) android:background="#c9ffffff"  ==> 앞의 알파값 c9을 주어서 배경이 뿌옇게 나온다.



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/full_layout"
xmlns:android="http://schemas.android.com/apk/res/android" android:background="#c9ffffff"
android:gravity="center">
<LinearLayout android:layout_width="170dip"
android:layout_height="240dip" android:background="@drawable/com_list_bg"
android:orientation="vertical">
<TextView android:text="할일 선택" android:id="@+id/textView1"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" style="@style/color222222_15" android:layout_marginTop="11dip"></TextView>
<ListView android:layout_height="wrap_content" android:id="@+id/listView1"
android:layout_width="match_parent" android:layout_marginLeft="3dip" android:layout_marginRight="3dip" android:layout_marginTop="4.5dip"></ListView>
</LinearLayout>

</LinearLayout>

댓글 없음:

댓글 쓰기