标签: android-styles

设置EditText光标颜色

我有这个问题,我在平板电脑项目中使用Android的Holo主题.但是,我在屏幕上有一个具有白色背景的片段.我EditText在这个片段上添加了一个组件.我试图通过设置Holo.Light主题资源的背景来覆盖主题.但是,我的文本光标(克拉)仍然是白色的,因此在屏幕上看不见(我可以在编辑文本字段中隐约发现它...).

有谁知道如何让EditText使用更暗的光标颜色?我已经尝试将EditText的样式设置为"@android:style/Widget.Holo.Light.EditText"没有正面结果.

android android-edittext android-styles

492
推荐指数
15
解决办法
28万
查看次数

为什么我的Button文本强制在Lollipop上的所有大写?

在我的应用程序"Tide Now WA"中,我最近使用新的Nexus 9平板电脑(Lollipop - API 21)测试了兼容性.

它会写一些按钮文字.此应用程序使用Android 2.3和Android 4.0正确编写文本.即混合资本和小写字母.

当我的Nexus 9上运行相同的应用程序时,文本中的所有字母都大写.

FWIW我的清单包含以下声明:

uses-sdk android:minSdkVersion="10" android:targetSdkVersion="14"

我可以在我的代码中修复此问题,还是操作系统中的错误感谢

android android-button android-styles android-5.0-lollipop

418
推荐指数
15
解决办法
18万
查看次数

Android工具栏中心标题和自定义字体

我正在尝试找出使用自定义字体作为工具栏标题的正确方法,并将其置于工具栏中(客户端要求).

目前,我正在使用旧的ActionBar,我将标题设置为空值,并使用setCustomView自定义字体TextView并使用ActionBar.LayoutParams将其居中.

有没有更好的方法呢?使用新工具栏作为我的ActionBar.

android android-layout android-theme android-styles android-toolbar

347
推荐指数
16
解决办法
34万
查看次数

使用appcompat v7更改EditText底线颜色

我正在使用appcompat v7来获得Android 5及更低版本的外观.它工作得很好.但是我无法弄清楚如何更改EditTexts的底线颜色和重点颜色.可能吗?

我试图定义一个自定义android:editTextStyle(参见下面),但我只是成功地改变了整个背景颜色或文本颜色,但没有改变底线和强调颜色.是否有特定的财产价值?我是否必须通过该android:background属性使用自定义可绘制图像?是不是可以用hexa指定颜色?

 <style name="Theme.App.Base" parent="Theme.AppCompat.Light.DarkActionBar">
     <item name="android:editTextStyle">@style/Widget.App.EditText</item>
 </style>

 <style name="Widget.App.EditText" parent="Widget.AppCompat.EditText">
     ???
 </style>
Run Code Online (Sandbox Code Playgroud)

根据android API 21的消息来源,EditTexts与材料设计似乎使用colorControlActivatedcolorControlNormal.因此,我试图在先前的样式定义中覆盖这些属性,但它没有任何效果.可能appcompat不使用它.不幸的是,我找不到上一版appcompat的材料设计来源.

java android android-layout android-edittext android-styles

303
推荐指数
18
解决办法
30万
查看次数

如何使用XML更改ActionBarActivity的ActionBar的背景颜色?

细节:

我正在扩展ActionBarActivity.
自2011-11-06起,Eclipse和SDK已完全修补.

<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14" />  
Run Code Online (Sandbox Code Playgroud)

使用Android 2.3.3
应用程序部署到三星设备android:theme="@android:style/Theme.Light"

问题:应用程序很轻,但ActionBar是蓝色的灰色图标,蓝色背景颜色几乎看不到.我也希望ActionBar很轻,所以它们的灰色图标更加明显.

我试过修改样式但无济于事.
我可能错过了一些微不足道的东西.

如何使用XML更改ActionBarActivity的ActionBar的背景颜色?

android android-theme android-actionbar android-styles

266
推荐指数
13
解决办法
47万
查看次数

如何更改新材质主题中后退箭头的颜色?

我已将我的SDK更新为API 21,现在后退/上移图标是指向左侧的黑色箭头.

黑色后箭头

我希望它是灰色的.我怎样才能做到这一点?

例如,在Play商店中,箭头为白色.

我这样做是为了设置一些风格.我已经习惯@drawable/abc_ic_ab_back_mtrl_am_alphahomeAsUpIndicator.drawable是透明的(只有alpha),但箭头显示为黑色.我想知道我是否能像我一样设置颜色DrawerArrowStyle.或者,如果唯一的解决方案是创建我的@drawable/grey_arrow并使用它homeAsUpIndicator.

<!-- Base application theme -->
<style name="AppTheme" parent="Theme.AppCompat.Light">

    <item name="android:actionBarStyle" tools:ignore="NewApi">@style/MyActionBar</item>
    <item name="actionBarStyle">@style/MyActionBar</item>

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

    <item name="homeAsUpIndicator">@drawable/abc_ic_ab_back_mtrl_am_alpha</item>
    <item name="android:homeAsUpIndicator" tools:ignore="NewApi">@drawable/abc_ic_ab_back_mtrl_am_alpha</item>
</style>

<!-- ActionBar style -->
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">

    <item name="android:background">@color/actionbar_background</item>
    <!-- Support library compatibility -->
    <item name="background">@color/actionbar_background</item>
</style>

<!-- Style for the navigation drawer icon -->
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
    <item name="spinBars">true</item>
    <item name="color">@color/actionbar_text</item>
</style>
Run Code Online (Sandbox Code Playgroud)

到目前为止,我的解决方案是采用@drawable/abc_ic_ab_back_mtrl_am_alpha看似白色的,并使用照片编辑器将其绘制成我想要的颜色.它的工作原理,但我更喜欢使用@color/actionbar_textDrawerArrowStyle.

java user-interface android colors android-styles

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

无法在styles.xml(Android Studio)中解析符号'Theme'

截图

从今天开始,Android Studio无法在styles.xml中找到AppCompat主题,但是例如代码中的AppCompatActivity确实得到了识别.我的Android Studio版本是2.2.2,Build#AI-145.3360264

我已经尝试升级到最新的构建工具,编译sdk(25)版本等,但它没有解决问题.

目前我安装了以下内容(来自sdk经理):

  • android api:19和23
  • sdk平台工具:25.0.1
  • sdk工具:25.2.3
  • 构建工具:23.0.2和25.0.1
  • 支持存储库:40
  • 谷歌存储库:39

和其他一些,这里没有必要列出.

app的build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '25.0.1'
    defaultConfig {
        applicationId "xxx.xxxxxxxx.xxxxxxxxx" //not the real applicationId
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {

        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile files('libs/RootTools.jar')
    compile 'com.android.support:support-v4:23.+'
    compile 'com.android.support:support-v13:23.+'
    compile 'com.android.support:appcompat-v7:23.+'
    compile 'com.android.support:design:23.+'
    compile 'com.android.support:cardview-v7:23.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4' …
Run Code Online (Sandbox Code Playgroud)

android android-appcompat gradle android-studio android-styles

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

styles.xml中的自定义属性

我创建了一个自定义小部件,我在layout.xml中声明它.我还在attr.xml中添加了一些自定义属性.但是,当尝试在styles.xml中的样式中声明这些属性时,它正在给我No resource found that matches the given name: attr 'custom:attribute'.

我已将xmlns:custom="http://schemas.android.com/apk/res/com.my.package"styles.xml中的所有标记放入,包括<?xml>,<resources><style>,但它仍然给我相同的错误,它无法找到我的自定义XML命名空间.

但是,我可以使用我的命名空间手动为layout.xml中的视图分配属性,因此命名空间没有任何问题.我的问题在于使styles.xml知道我的attr.xml.

android android-layout android-xml android-styles

174
推荐指数
5
解决办法
6万
查看次数

Android的XML属性中的问号(?)

谁能解释Android XML属性中的问号意味着什么?

<TextView    
    style="?android:attr/windowTitleStyle"
    More attributes
/>
Run Code Online (Sandbox Code Playgroud)

xml android android-styles

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

如何制作更小的RatingBar?

我在布局中添加了RatingBar:

<RatingBar 
    android:id="@+id/ratingbar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:numStars="5"
    android:stepSize="1.0"
    />  
Run Code Online (Sandbox Code Playgroud)

但评级栏的默认样式太大.
我试着通过添加android风格来改变它:style="?android:attr/ratingBarStyleSmall"

但结果太小,无法使用此属性设置费率.

我该怎么办?

android android-widget android-styles

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