标准 BottomSheetDialogFragment 将我的状态栏颜色更改为这种丑陋的绿色,并且我无法将其更改为任何其他颜色。尝试过这个,但它不起作用。有什么想法吗?
这是我的对话框类:
public class BottomSheetExample extends BottomSheetDialogFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.bottom_sheet, container, false);
// Code below only changes status bar color to black after bottom
// sheet closes, not while it's open like it should
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
getActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.colorBlack, null));
}
else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.colorBlack));
}
}
}
return v; …
Run Code Online (Sandbox Code Playgroud) 我正在尝试更改 Android 版 Flutter 启动屏幕上的状态栏颜色。但是,无论我做什么,它的颜色都保持不变(黑色)。我尝试过在 Android styles.xml 中设置 colorPrimaryDark、statusBarColor 和其他内容。有可能吗?
有谁知道当您使用windowTranslucentStatus = true时如何摆脱这种自动色调?我已经将状态栏颜色设置为透明,但是当启用windowTranslucentStatus时,它似乎将其覆盖。如果禁用windowTranslucentStatus,则可以得到所需的状态栏颜色,但无法再在状态栏下绘制导航抽屉。我可以使用ScrimInsetFrameLayout实现我想要的功能,但这引起了其他问题。
android android-4.4-kitkat android-5.0-lollipop android-statusbar
我一直在使用这些标志SYSTEM_UI_FLAG_FULLSCREEN
并SYSTEM_UI_FLAG_HIDE_NAVIGATION
隐藏和显示状态栏和导航栏。他们工作正常。我在活动开始时将它们隐藏起来,我想在触摸事件中再次显示它们。Android会在第一次触摸事件时自动显示它们(此第一次触摸事件不会传递给我的应用程序)。我想sendMessageDelayed()
在一段时间后用来隐藏两个栏。我如何使用此首次触摸事件?
如何知道系统UI何时在Android
启动过程中加载?状态栏和导航栏视图的确切位置在哪里?作为SystemUI
特权应用程序,它是否在启动器应用程序(主屏幕)启动之前加载?我不确定.任何建议都是受欢迎的.
如何在React Native应用程序中更改导航标题的颜色?
我尝试初始化背景色,但是没有用。
以下是我的代码段navigationOptions
:
static navigationOptions = ({ navigation }) => ({
header: props => <Header
navigation={navigation}
title={'Dashboard'}
toggleDrawer
/>
})
Run Code Online (Sandbox Code Playgroud)
另外,可以设置状态栏颜色吗?
我使用 Kotlin 创建一个 Android 应用程序,我想知道如何使用 Kotlin 使状态栏完全透明,并带有深色文本颜色 我看到了以下解决方案,但对我不起作用 带有不透明导航栏的深色文本透明状态栏 这是我的以下代码:
if (VERSION.SDK_INT in 19..20) {
setWindowFlag(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, true)
}
if (VERSION.SDK_INT >= 19) {
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
}
if (VERSION.SDK_INT >= 21) {
setWindowFlag(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false)
window.statusBarColor = Color.TRANSPARENT
}
Run Code Online (Sandbox Code Playgroud)
这是 style.xml 中的自定义样式:
<style name="MyStyle" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowNoTitle">true</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:navigationBarColor">@android:color/black</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
和我的 xml 代码:
<..... android:fitsSystemWindows="true" ....>
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="189dp"
app:elevation="0dp"
android:theme="@style/MyStyle" ....>
Run Code Online (Sandbox Code Playgroud)
我想知道我的代码中的问题出在哪里以及如何纠正它以使状态栏完全透明并带有深色文本颜色
我有一个屏幕,其中包含一个地图,我想让状态栏完全透明。
我尝试过的:
implementation "com.google.accompanist:accompanist-systemuicontroller:0.26.1-alpha"
@Composable
fun MapMainScreen() = Column(
modifier = Modifier.fillMaxSize()
) {
val controller = rememberSystemUiController()
controller.setStatusBarColor(color = Color.Transparent)
controller.setNavigationBarColor(color = Color.Transparent)
controller.setSystemBarsColor(color = Color.Transparent)
Map()
}
Run Code Online (Sandbox Code Playgroud)
另外,我在setContent调用之前和调用中尝试在 MainActivity 中使用窗口:
WindowCompat.setDecorFitsSystemWindows(window, false)
window.setFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
)
Run Code Online (Sandbox Code Playgroud)
我想看到像 Google 地图一样的结果,但现在我的状态栏颜色是白灰色而不是透明
我该如何解决这个问题并使我的状态栏透明?
我的问题是我想更改特定片段中状态栏的颜色。在所有其他片段中,颜色应该相同。例如,在所有片段中,我的状态栏颜色是红色。但在特定片段中,我想要将其更改为黑色。谁能告诉我我该怎么做?
这是我的片段的 onCreateView 方法:-
@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
final View view = (View) inflater.inflate(R.layout.slide_user_image, container, false);
Window window = getActivity().getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(getActivity().getResources().getColor(R.color.black));
return view;
}
Run Code Online (Sandbox Code Playgroud) 我有一个问题,当我使用包含片段中的图像视图的 CoordinatorLayout 时,我无法使状态栏透明并在状态栏下绘制图像视图(在活动中它没问题)。
为了说明问题,我以cheesesquare为例。
在 cheesesquare 中有一个 CheeseDetailActivity 显示了一些这样的内容(这是我想要的效果):
样式.xml(v21)
<资源>
<style name="Theme.DesignDemo" parent="Base.Theme.DesignDemo"> <item name="android:windowDrawsSystemBarBackgrounds">true <item name="android:statusBarColor">@android:color/transparent</style>
</资源>
活动细节.xml
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<ImageView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
Run Code Online (Sandbox Code Playgroud)
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="24dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/card_margin">
<LinearLayout
style="@style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Info"
android:textAppearance="@style/TextAppearance.AppCompat.Title" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/cheese_ipsum" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/card_margin"
android:layout_marginLeft="@dimen/card_margin"
android:layout_marginRight="@dimen/card_margin"> …
Run Code Online (Sandbox Code Playgroud)android android-fragments android-statusbar android-coordinatorlayout