标签: android-styles

如何设置Android Switch的样式?

API 14中引入的切换小部件默认使用holo主题进行样式设置.我想把它的风格略有不同,改变它的颜色和形状有点因为品牌的原因.怎么会这样呢?我知道它必须是可能的,因为我已经看到默认ICS和三星的touchwiz主题之间的区别

在此输入图像描述

我假设我需要一些状态drawables,我在http://developer.android.com/reference/android/R.styleable.html中看到了一些样式,Switch_thumb和Switch_track看起来像我之后的样子.我只是不知道如何使用它们.

我正在使用ActionbarSherlock,如果这有所作为.当然,只有运行API v14或更高版本的设备才能使用交换机.

android styling android-theme android-styles android-switch

118
推荐指数
2
解决办法
12万
查看次数

具有底部笔划的android形状

我需要创建一个android形状,以便只有底部有笔画(虚线).当我尝试以下操作时,笔划将形状从中心平分.有谁知道怎么做对吗?中风需要是底线/边界.我使用形状作为TextView的背景.请不要在意我为什么需要它.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item>
        <shape android:shape="rectangle" >
            <solid android:color="#1bd4f6" />
        </shape>
    </item>

    <item>
        <shape android:shape="line" >
            <padding android:bottom="1dp" />

            <stroke
                android:dashGap="10px"
                android:dashWidth="10px"
                android:width="1dp"
                android:color="#ababb2" />
        </shape>
    </item>

</layer-list>
Run Code Online (Sandbox Code Playgroud)

android layer-list android-drawable android-styles

111
推荐指数
9
解决办法
16万
查看次数

如何设置工具栏文本和后退箭头颜色

工具栏背景为深色,我希望文本和后退箭头为白色.我试过跟随,但它不起作用.

<style name="Theme.MyTheme" parent="Theme.AppCompat.Light.NoActionBar">

        <item name="colorPrimary">@color/blue</item>
        <item name="colorPrimaryDark">@color/blue_darker</item>
        <item name="colorAccent">@color/purple</item>
        <!-- item name="android:textColorPrimary">@color/white</item--> // I don't want to set this, changes everywhere. 
        <item name="android:textColorSecondary">@color/white</item>
        <item name="android:toolbarStyle">@style/AppTheme.ToolbarStyle</item>
        <item name="toolbarStyle">@style/AppTheme.ToolbarStyle</item>

        <item name="drawerArrowStyle">@style/AppTheme.DrawerArrowStyle</item>

    </style>

    <style name="AppTheme.ToolbarStyle" parent="Base.Widget.AppCompat.Toolbar">
        <!--<item name="actionOverflowButtonStyle">@style/AppTheme.OverflowButtonStyle</item>-->
        <item name="android:textColor">@color/white</item> // doesn't work
        <item name="titleTextAppearance">@style/TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse</item>
        <item name="android:titleTextAppearance">@style/TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse</item>
        <item name="subtitleTextAppearance">@style/TextAppearance.Widget.AppCompat.Toolbar.Subtitle</item>
    </style>
Run Code Online (Sandbox Code Playgroud)

android toolbar android-layout android-theme android-styles

107
推荐指数
9
解决办法
15万
查看次数

Android状态栏图标颜色

我想知道是否可以更改状态栏图标颜色(而不是状态栏颜色colorPrimaryDark) 在此输入图像描述 假设我想要这个状态栏:
<item name="colorPrimaryDark">@android:color/white</item>

和黑色的图标,这可能吗?

谢谢.

编辑:

M开发人员预览中的新功能:windowLightStatusBar.在主题中翻转它会告诉系统使用深色前景,对浅色状态栏很有用.请注意,M预览似乎有一个错误,通知图标保持白色,而系统状态图标正确地变为半透明黑色.

来自:Roman Nurik的 Google+ 帖子 在此输入图像描述

android android-styles android-5.0-lollipop android-statusbar

107
推荐指数
7
解决办法
9万
查看次数

你如何在Android XML中强调文本?

如何在XML文件中为文本加下划线?我找不到一个选项textStyle.

android underline textview android-styles

100
推荐指数
6
解决办法
13万
查看次数

如何以编程方式获得强调色?

如何以编程方式获取样式中的强调颜色集,如下所示?

    <item name="android:colorAccent">@color/material_green_500</item>
Run Code Online (Sandbox Code Playgroud)

android android-xml android-styles

82
推荐指数
7
解决办法
3万
查看次数

在样式中使用App命名空间

我将举一个例子来证明更重要的一点.

想象一下,我的应用程序有许多FloatingActionButtons.因此,我想创建一种样式并重用它.所以我做了以下事情:

<style name="FabStyle” parent ="Widget.Design.FloatingActionButton">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_margin">16dp</item>
    <item name="app:backgroundTint">@color/accent</item>
    <item name="app:layout_anchorGravity">end|bottom</item>
</style>
Run Code Online (Sandbox Code Playgroud)

我遇到的问题是代码没有编译,因为它抱怨

Error:(40, 5) No resource found that matches the given name: attr 'app:backgroundTint'.
Run Code Online (Sandbox Code Playgroud)

我尝试通过resources标记引入命名空间,但这不起作用

<resources
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    >
Run Code Online (Sandbox Code Playgroud)

有什么想法我可以让它工作?

android android-layout android-theme android-styles

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

styles.xml和themes.xml之间有什么区别

我可以知道styles.xml和之间的区别是themes.xml什么?对我来说,它们看起来一样,因为两种XML都采用相同的格式.

<style name="...
    <item name="...
Run Code Online (Sandbox Code Playgroud)

所以,在我的应用程序,它提供的定制颜色,尺寸,绘制,......我需要既styles.xmlthemes.xml呢?我该如何决定将哪个XML放在哪个文件中?

android android-theme android-styles

58
推荐指数
3
解决办法
1万
查看次数

Android工具栏:横向模式下的小标题文字

我在Android上测试新的工具栏和AppCompat主题并遇到了问题.我的工具栏标题文本在纵向模式下看起来是正常大小但在横向模式下变得相当小,尽管我在代码中没有做任何改变标题文本大小的事情.以下是截图:

肖像 景观

activity_main.xml中:

<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context="com.techfunmyanmar.jujaka.ui.MainActivity">

    <android.support.v7.widget.Toolbar
        android:id="@+id/main_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <!-- As the main content view, the view below consumes the entire
             space available using match_parent in both dimensions. -->
        <FrameLayout
            android:id="@+id/container"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <!-- android:layout_gravity="start" tells DrawerLayout to treat …
Run Code Online (Sandbox Code Playgroud)

android android-styles

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

操作栏菜单项文本颜色

如何更改菜单项标题的文本颜色.我试着改变它如下

<style name="Theme.Kanku.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
    <item name="android:textColor">@color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud)

但它仅更改操作栏标题文本的颜色,而不更改菜单项文本.

android android-menu android-actionbar android-styles

51
推荐指数
5
解决办法
7万
查看次数