How to implement transparency inBar status?
* minSdkVersion 16 Compatibility API
Create a style with colorPrimaryDark with transparency
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
...
</style>
<style name="AppTheme.StatusBar.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/actionBar</item>
<item name="colorPrimaryDark">#33000000</item>
<item name="colorAccent">@color/accent</item>
</style>
In AndroidManifest.xml associate style with activity
<activity android:theme="@style/AppTheme.StatusBar.Transparent"
android:name="TestActivity">
</activity>
In the onCreate method of activity, implement the statusBarTransparent
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.test_activity);
...
statusBarTransparent();
}
private void statusBarTransparent()
{
getWindow().getDecorView()
.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
DisplayMetrics dm = getResources().getDisplayMetrics();
int marginTop = (int) Math.ceil(25 * dm.density);
View view = findViewById(R.id.frmClient);
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
lp.setMargins(0,marginTop,0,0);
}
test_activity.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/mapBse"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<FrameLayout
android:id="@+id/frmClient"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:background="@drawable/frame_square">
<ImageView
android:id="@+id/imgMnu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingTop="8dp"
android:paddingRight="16dp"
android:paddingBottom="8dp"
android:src="@drawable/ic_menu_d"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/imgMnu"
android:layout_alignParentRight="true"
android:textColor="#999999"
android:textAppearance="@android:style/TextAppearance.Medium"
android:text="Pesquisar indicador"/>
</RelativeLayout>
</FrameLayout>
</FrameLayout>
Screen copy