티스토리 뷰

반응형

Stack Overflow에 자주 검색, 등록되는 문제들과 제가 개발 중 찾아 본 문제들 중에서 나중에도 찾아 볼 것 같은 문제들을 정리하고 있습니다.

Stack Overflow에서 가장 먼저 확인하게 되는 가장 높은 점수를 받은 Solution과 현 시점에 도움이 될 수 있는 가장 최근에 업데이트(최소 점수 확보)된 Solution을 각각 정리하였습니다.

 

아래 word cloud를 통해 이번 포스팅의 주요 키워드를 미리 확인하세요.

How do I create a transparent Activity on Android?

안드로이드에서 투명한 액티비티를 만들려면 어떻게 해야 하나요?

 문제 내용 

I want to create a transparent Activity on top of another activity.

다른 액티비티 위에 투명한 액티비티를 만들고 싶습니다.

 

How can I achieve this?

어떻게 하면 달성할 수 있을까요?

 

 

 

 높은 점수를 받은 Solution 

Add the following style in your res/values/styles.xml file (if you don’t have one, create it.) Here’s a complete file:

res/values/styles.xml 파일에 다음 스타일을 추가합니다(파일이 없는 경우 작성하십시오). 전체 파일은 다음과 같습니다.

 

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="Theme.Transparent" parent="android:Theme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:backgroundDimEnabled">false</item>
  </style>
</resources>

(The value @color/transparent is the color value #00000000 which I put in the res/values/color.xml file. You can also use @android:color/transparent in later Android versions.)

(@color/transparent 값은 res/values/color.xml 파일에 입력한 색상 값 #00000000입니다. 이후 안드로이드 버전에서 @android:color/transparent를 사용할 수도 있습니다.)

 

Then apply the style to your activity, for example:

그런 다음 스타일을 액티비티에 적용합니다. 예:

 

<activity android:name=".SampleActivity" android:theme="@style/Theme.Transparent">
...
</activity>

 

 

 가장 최근 달린 Solution 

2021 facts

2021년 사실

 

Just add

그냥 추가하세요
<item name="android:windowBackground">@android:color/transparent</item>

 

You're done.

모든 작업이 완료됩니다.

 

 

 

출처 : https://stackoverflow.com/questions/2176922/how-do-i-create-a-transparent-activity-on-android

반응형
댓글
공지사항
최근에 올라온 글