Ich habe eine App, die mit fitsSystemWindows einen Hintergrund hinter Navigations- und Statusleiste zeichnen kann - leider ignoriert die SnackBar die fitsSystemWindows = true aus dem Container. Ich gekocht, um das Problem auf diese minimale App:SnackBar und fitSystemWindow
der Stil:
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:windowBackground">@color/accent_material_dark</item>
<item name="android:fitsSystemWindows">false</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
</resources>
das Layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<Button
android:id="@+id/button"
android:text="@string/hello_world"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
der Aktivität:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
Snackbar.make(v,"This Snackbar should fitSystemWindows",Snackbar.LENGTH_INDEFINITE).show();
}
});
}
}
Anyon e weiß eine Abhilfe?
veröffentlichte ich die minimale App hier das Problem zu zeigen: https://github.com/ligi/SnackBarFitsSystemWindowProblem
Würde diese Kaskade von Fragment herunterkippen? Ich habe ein Fragment, in dem ich diese Snackbar spawne, aber –
@NeonWarge - Sie meinen, Kaskade von einem Fragment, dessen Ansicht in einem 'CoordinatorLayout' enthalten ist? Jep. – ianhanniballake
Ja, in der Tat, es gibt etwas, das es vermasselt. Es respektiert dieses Attribut nicht für mich:/Es ist ein ViewPager für eine Aktivität mit 4 Fragmenten. –