标签: android-theme

为Android应用程序设置Holo主题

我有一个简单的登录界面,包含用户名和密码.

我希望它能以EditText你在Ice Cream Sandwich和Honeycomb的Holo主题中看到的方式显示.

在我的清单文件中

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

现在文本字段不应该看起来不同,例如没有顶部,左侧和右侧边框吗?

我似乎看起来完全一样.我确信我做的事情基本上都是错误的,但欢迎任何建议.

这是我在模拟器中看到的: 屏幕截图2012-04-23 at 03.08.16

我期待更像这样:http: //developer.android.com/design/building-blocks/text-fields.html

android android-theme

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

在操作栏之外的下拉旋转器?(IceCream三明治风格,带ActionBarSherlock)

有没有办法为Android 2.3.3创建Dropdown Spinner?我正在使用ActionbarSherlock.

这是我的意思的一个例子:

在此输入图像描述

谢谢

android android-theme actionbarsherlock android-actionbar

12
推荐指数
1
解决办法
6867
查看次数

使用ActionBarSherlock时如何应用HoloEverywhere android主题?

我正在构建一个应该在android 2.3上运行的应用程序,我添加了ActionBarSherlock和HoloEverywhere库.

为了使用ActionBarSherlock,我必须像这样使用Theme.Sherlock:

<application
    ...
    android:theme="@style/Theme.Sherlock"
    ...  >
Run Code Online (Sandbox Code Playgroud)

那没关系.

我的主要活动非常简单:只有一个包含5行的ListView(我不使用ListAcivity).

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ListView
        android:id="@+id/menuListView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

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

因为它是android 2.3,我仍然有橙色和黑色主题(当然除了ActionBar).现在我想通过修改我的清单来添加HoloEverywhere主题:

<application
    ...
    android:theme="@style/Theme.HoloEverywhereDark.Sherlock"
    ...  >
Run Code Online (Sandbox Code Playgroud)

但这并没有改变任何事情......我错过了什么?

android android-theme actionbarsherlock android-actionbar android-holo-everywhere

12
推荐指数
1
解决办法
9447
查看次数

ActionBarSherlock上的activatedBackgroundIndicator的自定义背景不起作用

我正在使用ActionBarSherlock,我正在尝试为行背景自定义activatedBackgroundIndicator属性.

如果我使用最新的android sdk,没有ActionBarSherlock,我可以自定义背景,在res/values/style.xml上创建以下样式,并在AndroidManifest.xml上将其定义为android:theme ="@ style/Theme.自定义":

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="Theme.Custom" parent="android:Theme.Holo.Light.DarkActionBar">
     <item name="android:activatedBackgroundIndicator">@drawable/activated_background</item>
  </style>
</resources>
Run Code Online (Sandbox Code Playgroud)

然后,我的res/drawable/activated_background.xml包含下一个代码:

<selector xmlns:android="http://schemas.android.com/apk/res/android">  
   <item android:state_activated="true" android:drawable="@color/row_activated" />
   <item android:drawable="@android:color/transparent" />  
</selector>
Run Code Online (Sandbox Code Playgroud)

最后,用于定义ListView中每一行的代码是:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:background="?android:attr/activatedBackgroundIndicator">
    <TextView
            android:id="@+id/test_row"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/sample_string"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:padding="15dp"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

结果显示在屏幕截图中.是一个简单的应用程序,当单击列表项时,只有ListView与ListView.CHOICE_MODE_SINGLEgetListView().setItemChecked(position,true).

标准所选行的蓝色现在是黄色并且完美地运行.

没有ABS的清单

当我想使用ActionBarSherlock应用相同的自定义时,会出现此问题.现在样式文件是下一个,背景显示为蓝色而不是自定义黄色.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.Custom" parent="Theme.Sherlock.Light.DarkActionBar">
        <item name="activatedBackgroundIndicator">@drawable/activated_background</item>
        <item name="android:activatedBackgroundIndicator">@drawable/activated_background</item>
    </style>

    <style name="activatedBackgroundIndicator"> …
Run Code Online (Sandbox Code Playgroud)

android background android-layout android-theme actionbarsherlock

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

使用"activatedBackgroundIndicator"导航抽屉选择项目的自定义背景颜色

这个问题在SO上已经被问了很多,我已经引用了所有的答案.我的导航抽屉上的所选项目仍然保留默认的Holo蓝色背景.我是Java新手,我对"上下文"部分感到困惑.setAdapter().
我的项目是一个Activity,使用导航抽屉交换了多个片段.

这是我的适配器:

mDrawerListView.setAdapter(new ArrayAdapter<String>(
            // First parameter - Context
            getActionBar().getThemedContext(),
            // Second parameter - Layout for the row
            R.layout.fragment_navigation_drawer_list_item,
            // Third parameter - ID of the TextView to which the data is written
            android.R.id.text1,
            // Forth - the Array of data
            new String[]{
                    getString(R.string.title_section1),
                    getString(R.string.title_section2),
                    getString(R.string.title_section3),
                    getString(R.string.title_section4),
            }));
    mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
Run Code Online (Sandbox Code Playgroud)

这里的上下文来自Android Studio中的"预先烹饪"导航抽屉.我认为这将是所选项目的导航抽屉项目背景颜色的答案.所以我改变了我的上下文getActivity().getBaseContext(),,但这并没有改变任何东西.

我的主题(styles.xml):

<resources>
    <style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <!-- API 14 theme customizations can go here. -->
        <item name="android:actionBarStyle">@style/ActionBar</item>
    </style>

    <!-- Navigation …
Run Code Online (Sandbox Code Playgroud)

android android-theme android-fragments

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

如何自定义AppCompat材质按钮样式?

我正在使用AppCompat主题,我想在我的按钮上设置minHeight属性:

<style name="Theme.MyTheme" parent="Theme.AppCompat">
    <item name="android:buttonStyle">@style/MyButtonStyle</item>
</style>

<style name="MyButtonStyle" parent="...?">
    <item name="android:minHeight">60dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)

但是,没有Widget.AppCompat.Button样式可以设置为父项MyButtonStyle.如果我使用android:Widget.Button,那么我的所有按钮看起来都像旧的蹩脚风格.我尝试了各种其他AppCompat主题TextAppearance.AppCompat.Button,但它们不起作用.

省略按钮样式的父主题也会导致按钮无法正确设置样式.

如何自定义默认值Theme.AppCompat buttonStyle

android android-appcompat android-ui android-theme

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

如何在Light Appcompat主题中使用来自黑暗主题的SearchView

我正在使用Theme.AppCompat.Light主题并使用SearchView,它默认显示深色文本和图标.

如何在这个光主题中使用Theme.AppCompat中定义的SearchView?

已经尝试过以下但没有工作?

<style name="Theme.App.Light" parent="Theme.AppCompat.Light">
   <item name="searchViewStyle">@style/Widget.AppCompat.SearchView</item>
</style> 
Run Code Online (Sandbox Code Playgroud)

即使使用Theme.AppCompat.Light.DarkActionBar作为基本主题也不会显示白色文本和图标..

它可以通过覆盖所有值来完成,但我只需要使用Dark主题中提供的默认值.

android android-appcompat android-theme

12
推荐指数
1
解决办法
3792
查看次数

在v19/v21中重复样式

我有这个styles.xml:

<style name="UserTheme" parent="ThemeBase">
    <item name="android:editTextStyle">@style/EditTextTheme</item>
</style>
Run Code Online (Sandbox Code Playgroud)

为什么我必须editTextStylev19/styles.xml和中重复这一行v21/styles.xml.

v21/styles.xml:

<style name="UserTheme" parent="ThemeBase">
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
    <item name="android:editTextStyle">@style/EditTextTheme</item>
</style>
Run Code Online (Sandbox Code Playgroud)

有没有办法在主要styles.xml地方调用它并让它适用于所有地方,所以我不必多次写它?

android android-layout android-xml android-theme android-styles

12
推荐指数
3
解决办法
2616
查看次数

TextInputLayout:未聚焦时提示标签的颜色不同

我想做的事:

使用嵌入在TextInputLayout中的EditText时我想...

  1. 将标签的颜色设置为去焦点时将其设置为绿色并浮动在EditText上方,因为用户已经输入了一些值
  2. 将标签的颜色设置为非焦点并位于EditText内时,因为用户尚未输入值
  3. 我不想将所有EditTexts的提示文本颜色更改为RED,但仅当它们被包装在TextInputLayout中时(我不需要一般方法 - 一种特定的方法,如为每个TextInputLayout设置主题/样式)布局XML会很好)
  4. 当用户聚焦场时,保留(即不改变)用于为浮动标签着色的强调色(黄色).

我尝试过的:

在TextInputLayout上将下面设置为主题/样式确实满足1.但不满足2.

<style name="FloatingLabel" parent="Widget.Design.TextInputLayout">
    <item name="android:textColorHint">@color/red</item>
</style>
Run Code Online (Sandbox Code Playgroud)

在我的嵌入式EditText上设置特定颜色,将提示文本更改为另一种颜色:

 android:textColorHint="@color/text_placeholder_gray"
Run Code Online (Sandbox Code Playgroud)

当标签从其浮动位置移回Edittext作为提示(即没有文本)时,实际上会导致提示文本重叠.

设置这个:

<style name="TextAppearence.App.TextInputLayout" parent="@android:style/TextAppearance">
<item name="android:textColor">@color/main_color</item>
Run Code Online (Sandbox Code Playgroud)

在TextInputLayout上:

 <android.support.design.widget.TextInputLayout
  ...
   app:hintTextAppearance="@style/TextAppearence.App.TextInputLayout" >
Run Code Online (Sandbox Code Playgroud)

更改提示标签颜色,但它也适用于聚焦状态 - 这意味着4不满足.

因为一张图片说的超过千字(所有字段都处于非聚焦状态):

在此输入图像描述

如何实现满足标准1-4的设置?

android android-layout android-theme android-styles

12
推荐指数
1
解决办法
2829
查看次数

WindowBackground可以定位在状态栏下方和导航栏上方吗?

基于本教程这个答案,也引用了这个其他教程,使用主题android:windowBackground和一个<layer-list/>似乎是最批准的创建Android启动画面的方法

使用这种技术将徽标集中在屏幕上很容易; 但是,我想在屏幕的顶部或底部放置图形.我遇到了问题,因为如下面的屏幕截图所示,windowBackground屏幕顶部的状态栏和底部的导航栏背后都显示出来,因此图形显示为截止



问题: 是否可以指示将windowBackground自己定位在状态栏下方和导航栏上方?如果没有,使用windowBackground启动画面技术是否可以创建状态栏或导航栏未涵盖的启动画面?

要重现该问题,请创建一个新的Android Studio项目,该项目将为您提供ic_launcherdrawable并按照上面链接的其中一个教程但使用以下layer-listdrawable

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:opacity="opaque">
    <item android:drawable="#000000"/>
    <item>
        <bitmap
            android:gravity="left|top"
            android:src="@drawable/ic_launcher"/>
    </item>
    <item>
        <bitmap
            android:gravity="center"
            android:src="@drawable/ic_launcher"/>
    </item>
    <item>
        <bitmap
            android:gravity="bottom"
            android:src="@drawable/ic_launcher"/>
    </item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)

android splash-screen android-layout android-theme

12
推荐指数
1
解决办法
2074
查看次数