Tôi có một ứng dụng sử dụng fitsSystemWindows để có thể vẽ nền sau Navigation- và Status-Bar - tiếc là SnackBar dường như bỏ qua fitsSystemWindows = true từ container. Tôi luộc vấn đề xuống ứng dụng tối thiểu này:SnackBar và fitsSystemWindow
phong cách:
<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>
bố trí:
<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>
hoạt động:
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 biết một số cách giải quyết?
tôi công bố ứng dụng tối thiểu để hiển thị các vấn đề ở đây: https://github.com/ligi/SnackBarFitsSystemWindowProblem
Thao tác này có bị đổ xuống từ Phân đoạn không? Tôi có một mảnh mà tôi đẻ trứng Snackbar này mặc dù –
@NeonWarge - Bạn có nghĩa là tầng lên từ một mảnh có xem được chứa trong một 'CoordinatorLayout'? Yup. – ianhanniballake
có, trên thực tế, có điều gì đó làm rối tung nó lên. Nó không tôn trọng thuộc tính đó cho tôi:/Một ViewPager của nó trên một hoạt động với 4 đoạn. –