07 Aug 2019 in Devstory on Android, Ui, Dim, Statusbar, Navigationbar, Systembar, Systemui, Visibility Show Dim The System BarsStatusBar 및 NavigationBar 를 dimmed 처리 할 수 있는 방안에 대해서 다룹니다. Android 4.0 (API 14) 이상에서 동작하며, 이전 버전에서는 dimmed 할 수 있는 빌트인된 API를 제공하지는 않습니다. 아래 API를 사용해서 System Bar를 dimmed 되게 처리할 수 있습니다. 사용자가 해당 bar를 터치하면, dimmed 처리가 사라지고 완전하게 보여지게 됩니다.
Dim the system barsSYSTEM_UI_FLAG_LOW_PROFILE 플래그를 사용하면, SystemBar의 Dimmed 처리를 할 수 있습니다.
Undim the system bars programmatically만약 코드상으로 undimmed 처리를 원한다면 다음과 같이 호출해줍니다.
어플 개발 안드로이드 Transparency(투명) 및 Dim(희미하게) 처리 방법출처 : http://www.androidcompetencycenter.com/2009/10/ 안드로이드 Transparency(투명) 및 Dim(희미하게) 처리 방법 Hello coders, Lets look at a fairly simple example of creating a transparent theme and how to apply it to a Dialog…… Step 1> Create a colors.xml file in the ‘values’ folder under ‘res’ and add the following line.. <drawable name="transparent">#00000000</drawable> Step 2> Create a styles.xml file in the ‘values’ folder under ‘res’ and the following lines… <style name="Transparent"> <item name="android:windowIsTranslucent">true</item> <item name="android:windowAnimationStyle"> @android:style/Animation.Translucent </item> <item name="android:windowBackground">@drawable/transparent</item> <item name="android:windowNoTitle">true</item> <item name="android:colorForeground">#fff</item> </style> ( I guess the tags and attributes are self explanatory …. ) Step 3> Actually thats it…………………… Let’s add this to a dialog….. Step 4> Create a class with the following lines…… public class DialogBox extends Dialog { public DialogBox(Context context, int theme) { super(context, theme); setContentView(R.layout.dialog); okButton = (Button) findViewById(R.id.dialog_OkButton); setListeners(); } } (Make sure you create a layout for the dialog ) Step 5> Next create an activity class as follows…. public class T_Temp extends Activity { private DialogBox dialog; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); dialog = new DialogBox(this, R.style.Transparent); dialog.show(); } } When creating the dialog just add the transparent theme …… Step 6> That’s it … ( don’t forget to add the activity in the android manifest file..) When you add the widgets and background it will look something like this.. Before
After
Step 7> Another trick is you can make the background blurred …. just add the following line in the dialog box… getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND); Output looks somthing like this…….
So the final code is: public class DialogBox extends Dialog { public DialogBox(Context context, int theme) { super(context, theme); getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND); setContentView(R.layout.dialog); okButton = (Button) findViewById(R.id.dialog_OkButton); setListeners(); } } |