Activity类中:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//透明状态栏
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//透明导航栏
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
Layout布局文件中:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:fitsSystemWindows="true"
android:clipToPadding="true"
android:background="@drawable/test_bg"
android:orientation="horizontal" >
绳锯木断,水滴石穿。海纳百川,积少成多。一分耕耘,一份收获。