标签: android-styles

当primaryDark为白色时更改状态栏文本颜色

我正在尝试重现Google日历应用程序的行为: 在此输入图像描述

但我还没有找到改变状态文本颜色的方法.如果我将colorPrimaryDark设置为白色,我无法看到图标既不是状态栏的文本也不是因为它们的颜色也是白色.

有没有办法改变状态栏文字颜色?

提前致谢

android android-styles android-statusbar

50
推荐指数
5
解决办法
4万
查看次数

MaterialComponents主题警告对话框按钮

最近我从支持库切换到com.google.android.material:material:1.0.0

但是现在我有一个问题,在这个页面上有一个注释https://github.com/material-components/material-components-android/blob/master/docs/getting-started.md

注意:使用"材质成分"主题可启用自定义视图填充程序,该填充程序将使用"材质"对应项替换默认组件.目前,这仅使用MaterialButton替换Button XML组件.

我正在使用的主题

Theme.MaterialComponents.Light.NoActionBar
Run Code Online (Sandbox Code Playgroud)

它完全按照它在说明中所说的,它将AlertDialog按钮替换为MaterialButtons,但问题是默认情况下MaterialButtons是彩色背景,现在按钮看起来像这样: 在此输入图像描述

我怎样才能让它们再次无边界和无背景?

PS我正在使用警报构建器来创建警报对话框:

android.app.AlertDialog.Builder
Run Code Online (Sandbox Code Playgroud)

android android-alertdialog android-styles material-design material-components-android

49
推荐指数
7
解决办法
8552
查看次数

如何将ProgressBar的样式更改为小?

我在找到指定进度条应该具有小的不确定样式的正确方法时遇到了一些困难.

如果有人可以为我和其他人快速搜索这些信息,我会很高兴.

android android-progressbar android-styles

46
推荐指数
5
解决办法
4万
查看次数

Android CollapsingToolbarLayout标题背景

我正在使用新Android设计支持库中的CollapsingToolbarLayout.

我已经设置了它的标题并且它工作正常,我仍然唯一的问题是当你滚动时,文本会丢失,具体取决于背景中的图像.

我想做的是设置CollapsingToolbarLayout标题的背景,但我还没有办法做到这一点.

反正有没有实现这个目标?

谢谢!

布局:

<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="@dimen/detail_backdrop_height"
    android:fitsSystemWindows="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginEnd="64dp"
        app:expandedTitleMarginStart="48dp"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <ImageView
            android:id="@+id/ivBigImage"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            android:scaleType="centerCrop"
            app:layout_collapseMode="parallax"/>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

    </android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_gravity="fill_vertical"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:paddingTop="24dp">

        <android.support.v7.widget.CardView
            android:id="@+id/cvDescription"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp">

            <LinearLayout
                style="@style/Image.Info.CardContent"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/description"
                    android:textAppearance="@style/TextAppearance.AppCompat.Title"/>

                <TextView
                    android:id="@+id/tvDescription"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text=""/>

            </LinearLayout>

        </android.support.v7.widget.CardView>


    </LinearLayout>

</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)

在活动中设置CollapsingToolbarLayout标题:

CollapsingToolbarLayout collapsingToolbar = …
Run Code Online (Sandbox Code Playgroud)

android android-styles android-support-design android-collapsingtoolbarlayout

46
推荐指数
2
解决办法
3万
查看次数

如何更改DialogFragment周围的背景颜色?

我正在建立一个习惯DialogFragment.对话框布局设置为my_dialog.xml,但如何修改对话框周围的颜色(透明灰色)?

在此输入图像描述

my_dialog.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center" >

    <TextView
        android:id="@+id/hello"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="@android:color/holo_orange_light"
        android:gravity="center"
        android:text="hello" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

MyDialogFragment.java

public class MyDialogFragment extends DialogFragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.my_dialog, container);

        getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

        return view;
    }
}
Run Code Online (Sandbox Code Playgroud)

android background android-dialogfragment android-styles

41
推荐指数
4
解决办法
6万
查看次数

AlertDialog样式 - 如何更改标题,消息等的样式(颜色)

我已经突破了这个问题.我需要做的是,AlertDialog在我的Android应用程序中更改所有s 的样式- 对话框背景需要是white-ish,文本需要是black-ish.我尝试创建了很多样式,主题,并从代码,清单等应用,但没有成功,关于内部的文本颜色AlertDialog.现在,我有最简单的代码,设置如下:

表现:

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
Run Code Online (Sandbox Code Playgroud)

styles.xml:

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:alertDialogStyle">@style/DialogStyle</item>
</style>

<style name="DialogStyle" parent="@android:style/Theme.Dialog">
    <!-- changing these background stuff works fine -->
    <item name="android:bottomBright">@android:color/white</item>
    <item name="android:bottomDark">@android:color/white</item>
    <item name="android:bottomMedium">@drawable/dialog_footer_bg</item>
    <item name="android:centerBright">@android:color/white</item>
    <item name="android:centerDark">@drawable/dialog_body_bg</item>
    <item name="android:centerMedium">@android:color/white</item>
    <item name="android:fullBright">@color/orange</item>
    <item name="android:fullDark">@color/orange</item>
    <item name="android:topBright">@color/green</item>
    <item name="android:topDark">@drawable/dialog_header_bg</item>
Run Code Online (Sandbox Code Playgroud)

下面列出的项目不起作用(请阅读我在每个元素上面的评论):

    <!-- panelBackground is not getting set to null, there is something squarish around it -->
    <item name="android:panelBackground">@null</item>

    <!-- Setting this textColor doesn't seem to have any effect at …
Run Code Online (Sandbox Code Playgroud)

android android-theme android-alertdialog android-styles

40
推荐指数
5
解决办法
10万
查看次数

如何自定义切换按钮?

我期待自定义Switch按钮变为如下:

在此输入图像描述

怎么做到这一点?

android android-button android-styles android-switch

40
推荐指数
10
解决办法
10万
查看次数

如何在Android中更改EditText的焦点颜色

如何更改EditText框上的焦点颜色(橙色)?对焦颜色是整个控件周围的小边缘,当控件具有焦点时为亮橙色.如何将焦点的颜色更改为其他颜色?任何人都可以帮我解决这个问题吗?提前致谢,

android android-edittext android-styles

39
推荐指数
1
解决办法
7万
查看次数

如何在android中更改DatePicker的样式?

我想更改Android中日期/时间选择器对话框的默认颜色,以便它应该与我的应用程序的主题相匹配.我在Google上搜索了解决方案,但我找不到解决方案.

我正在做的是创造一种新的风格:

  <style name="datepicker" parent="@android:style/Widget.DeviceDefault.DatePicker">
    <!---TODO-->
    <item name="android:focusedMonthDateColor">@android:color/holo_red_dark</item>
</style>
Run Code Online (Sandbox Code Playgroud)

不知道日期选择器对话的可用属性是什么.如果有人能发布链接就会很棒

添加样式后,我将其称为主要样式

 <item name="android:datePickerStyle">@style/datepicker</item>
Run Code Online (Sandbox Code Playgroud)

不幸的是,这对我来说根本不起作用.

android android-datepicker android-timepicker android-styles

39
推荐指数
8
解决办法
8万
查看次数

使用带有白色背景颜色的?selectableItemBackground

单击android:background="?selectableItemBackground"视图(LinearLayout例如)时,我一直在使用涟漪效果.我想我在某处读到这是向后兼容API 14的.

但是,我发现我需要使用这种涟漪效果,但背景为白色.具体来说,我有一个列表项的布局,它将显示在默认的颜色背景上(我正在延伸Theme.AppCompat.Light.NoActionBar),所以我想通过将列表项着色为白色(#FFFFFF)来使列表项从这个背景中脱颖而出.

这是列表项布局:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="?selectableItemBackground"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    ...

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:paddingLeft="@dimen/mdu_keyline_1"
        android:paddingRight="@dimen/mdu_keyline_1"
        android:paddingTop="@dimen/mdu_padding_normal"
        android:paddingBottom="@dimen/mdu_padding_normal">

        ...

    </LinearLayout>

</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

以上产生没有白色背景的涟漪效应.

如果我尝试:

<FrameLayout ...
    android:background="@color/white">
Run Code Online (Sandbox Code Playgroud)

这显然会产生白色背景但没有涟漪效应.

我也尝试了其他的东西 - 这产生了一个最接近我想要的结果:

<FrameLayout ...
    android:background="@color/white">

    ...

    <LinearLayout ...
        android:background="?selectableItemBackground">
Run Code Online (Sandbox Code Playgroud)

上面给了我带有涟漪效果的白色背景.但是,无论我点击哪一部分项目,纹波似乎总是从中心开始.

下面是一些截图显示了当前的结果(忽略在列表项的顶部的阴影-这是从影子AppBarLayoutToolbar我使用).

在此输入图像描述

在此输入图像描述

我怎样才能达到预期的效果?

android android-styles

39
推荐指数
4
解决办法
2万
查看次数