标签: android-theme

Android Studio:渲染问题缺少为此布局选择的样式 - 正确主题,无法找到具有id的样式

我想创建卡项xml布局CardView并获取此错误.这里的常见解决方案没有奏效(尝试过所有这些以及其他类似帖子).

这是我的xml:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.CardView
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        card_view:cardCornerRadius="3dp"
        card_view:cardElevation="4dp">


    </android.support.v7.widget.CardView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

这是以下相关部分styles.xml:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <item name="colorAccent">@color/primary_accent</item>
</style>

<!--Theme for Tool Bar (Action Bar)-->
<style name="ToolBarTheme" parent="ThemeOverlay.AppCompat.ActionBar">
    <item name="android:textColorPrimary">@color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud)

这是以下相关部分Manifest:

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

这是gradle build脚本的相关部分:

compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-xml android-theme android-studio

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

Android:状态栏颜色更改,API级别低于21

我正在尝试更改状态栏颜色,API级别低于21.通过更改主题样式中的主要颜色,我们可以更改API级别21的状态栏中的颜色.

应用商店

我正在寻找如何更改较低版本的状态栏颜色

谁能帮帮我吗 ?

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

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

为什么以及何时需要将android:前缀添加到样式中?

我已经看到一些Style属性需要android前缀,有些不需要它.是什么原因.喜欢

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)

为什么我们没有使用android:windowActionBarandroid:windowNoTitle

android styles android-theme

16
推荐指数
1
解决办法
1880
查看次数

android:theme ="@ android:style/Theme.NoTitleBar.Fullscreen"适用于应用程序级别,但不适用于活动级别.任何线索?

我需要将我的一项活动称为MyNoStatusBarActivity.java全屏活动.

我在Manifest中添加了:

<activity
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    android:name=".MyNoStatusBarActivity"
    android:noHistory="true"
    android:label="@string/app_name"
    android:configChanges="touchscreen|keyboard|keyboardHidden|navigation|orientation">
    ...
</activity>
Run Code Online (Sandbox Code Playgroud)

onCreate我的活动中:

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    getWindow().setFlags(
        WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
Run Code Online (Sandbox Code Playgroud)

这样做只是隐藏TITLE栏而不是STATUS栏.

此外,如果我在应用程序级别使用清单主题而不是我的活动,它可以工作,但我的应用程序的所有活动,这不是我想要的.我想只为一个特定的活动禁止状态栏.

帮助将非常感激.日Thnx!

PS:我很好,这种行为在Honeycomb/ICS中不再可用.我只需要2.2和2.3就可以了

编辑

尝试了SO中其他解决方案中提到的所有建议但尚未成功.应用于应用程序级别但不适用于活动级别时,主题可用.

我正在使用HTC WildFire-S,android ver 2.3.5

android statusbar android-manifest android-theme android-activity

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

在Android 4上自定义ActionBar选项卡

我正在尝试在ActionBar上自定义Tabs.我只想将标签对齐到手机屏幕,使其可以伸展各种屏幕.但我得到的只是:

在此输入图像描述

我用于主题的代码是这样的:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="MyTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:actionBarTabTextStyle">@style/MyActionBarTabTextStyle</item>
    </style>

    <style name="MyActionBarTabTextStyle" parent="@android:style/Widget.Holo.Light.Tab">
        <item name="android:textSize">14dip</item>
        <item name="android:padding">0dip</item>
    </style>

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

是否可以减少字体并摆脱那些蓝线?

提前感谢您的帮助.

PS:Button也很奇怪.这是没有文字(虽然它应该是)......

java android android-layout android-theme android-actionbar

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

没有标题栏Android主题

在我的应用程序中我想使用Theme.NoTitleBar,但另一方面我也不想放松Android操作系统的内部主题..我在网上搜索并找到以下答案..我修改了我的styles.xml并添加了以下代码行..

内部值/ styles.xml

<style name="Theme.Default" parent="@android:style/Theme"></style>
<style name="Theme.NoTitle" parent="@android:style/Theme.NoTitleBar"></style>
<style name="Theme.FullScreen" parent="@android:style/Theme.NoTitleBar.Fullscreen"></style>
Run Code Online (Sandbox Code Playgroud)

内部值-v11/styles.xml

<style name="Theme.Default" parent="@android:style/Theme.Holo"></style>
<style name="Theme.NoTitle" parent="@android:style/Theme.Holo.NoActionBar"></style>
<style name="Theme.FullScreen" parent="@android:style/Theme.Holo.NoActionBar.Fullscreen"></style>
Run Code Online (Sandbox Code Playgroud)

内部值-v14/styles.xml

<style name="Theme.Default" parent="@android:style/Theme.Holo.Light"></style>
<style name="Theme.NoTitle" parent="@android:style/Theme.Holo.Light.NoActionBar"></style>
<style name="Theme.FullScreen" parent="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"></style>
Run Code Online (Sandbox Code Playgroud)

在Manifest文件的应用程序标记中,我添加了一个属性:

android:theme="@style/Theme.NoTitle"
Run Code Online (Sandbox Code Playgroud)

但是当我尝试运行代码时我的应用程序中的图像变得模糊..但是当我使用以下标记时:

android:theme="@android:style/Theme.NoTitleBar"
Run Code Online (Sandbox Code Playgroud)

要么

android:theme="@android:style/Theme.Light.NoTitleBar"
Run Code Online (Sandbox Code Playgroud)

要么

android:theme="@android:style/Theme.Black.NoTitleBar"
Run Code Online (Sandbox Code Playgroud)

应用程序中的图像格式正确...但在这种情况下,我丢失了新Android操作系统上的所有主题..

请帮助我如何在不丢失图像和原生主题的情况下使用NoTitleBar主题..

布局代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainScreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<include
    android:id="@+id/main_top_bar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    layout="@layout/top_bar_title" />

<RelativeLayout
    android:id="@+id/container_bar1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/main_top_bar"
    android:layout_marginTop="-3dp"
    android:background="@drawable/tab_nav_bar" >
</RelativeLayout>

<RelativeLayout
    android:id="@+id/container_bar2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/container_bar1"
    android:background="@drawable/location_nav_bar" >

    <TableLayout
        android:id="@+id/map_bar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true" …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-theme

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

更改Android Actionbar字幕颜色

我希望自定义我的android应用程序的actionBar.
我正在使用Actionbar Sherlock.
我的最小目标sdk是14,目标sdk 17.
我有一个主题,改变背景颜色和主标题文本,
但我不能改变
我的风格在这里显示的字幕文字颜色

<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/MyTheme.ActionBarStyle</item>
</style>

<style name="MyTheme.ActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
    <item name="android:background">#8B0000</item>
</style>

<style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
    <item name="android:textColor">#FFFFFF</item>

</style>

<style name="MyTheme.ActionBar.Subtitle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Subtitle">
    <item name="android:textColor">#FF0000</item>

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


做错了什么?

android android-theme actionbarsherlock

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

如何为应用程序设置主题,以避免错误的颜色过渡?

背景

我正在我的"app manager"应用程序中开发主题选择器功能,并且我已成功为每个活动动态设置主题.

再次:这不是关于为活动设定主题.这实际上适合我.

问题

这些活动正在显示正确的主题,但应用程序本身在启动应用程序时,无论我做什么,都会显示错误的主题.

这是一个问题,因为当用户打开应用程序时,他将看到应用程序主题的背景,并且仅在片刻之后,活动将显示用户选择的主题.

因此,如果应用程序具有白色背景,并且用户选择了具有黑色背景的主题,则顺序将为:

应用程序显示白色背景 - >活动正在启动并显示黑色背景.

在截图中:

在此输入图像描述

所以这是错的.在这种情况下,我需要它来显示黑色到黑色的背景.

仅当用户选择了基于Holo-light的主题(默认情况下应用程序具有此主题)时,它才能正常工作,因为颜色与打开应用程序时右侧显示的活动上的颜色相匹配.

我试过的

我有一个想法,设置应用程序的主题是空的一切,希望没有显示过渡,使用类似的东西:

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

事实上,这里的一些人提出了类似的解决方案.

这有效,但它会导致糟糕的体验,因为在某些设备上显示第一个活动需要一些时间,因此,用户有很长时间没有看到任何内容,就像应用程序不是正在推出.

这个问题

我该如何解决这个问题?

我已经尝试在从Application扩展的类中设置主题,但它不会做任何事情,无论我在这个类中调用它.

android android-theme

15
推荐指数
2
解决办法
5053
查看次数

appcompat_v7:检索项目的父项时出错:找不到与给定名称匹配的资源

我正在尝试构建使用appcompat_v7库的Android项目.

为此,我通过Eclipse创建了我的项目 - > New Android Sample Project并添加了我的自定义styles.xml,然后添加了appcompat_v7库Project - > Properties - > Android - > Add.

但是当我编译项目时,我在appcompat_v7/res/values/styles_base.xml中收到以下错误:

appcompat_v7/res/values/styles_base.xml:24: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'.

appcompat_v7/res/values/styles_base.xml:84: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'.

appcompat_v7/res/values/styles_base.xml:166: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base'.

appcompat_v7/res/values/styles_base.xml:243: error: Error retrieving parent for item: No resource found that matches the given …
Run Code Online (Sandbox Code Playgroud)

android coding-style android-appcompat android-theme android-styles

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

android属性中格式引用的含义

让我们从一个例子开始吧

<attr name="spinnerDropDownItemStyle" format="reference" />
Run Code Online (Sandbox Code Playgroud)

我如何区分并理解它?

我看到Android主题和风格揭秘 - 谷歌I/O 2016多次谈话,我仍然不明白这个参考的东西是如何工作的.

android android-layout android-theme android-styles

15
推荐指数
1
解决办法
5250
查看次数