标签: android-theme

如何在Android中更改菜单主题

我的android应用程序使用以下样式:

<style name="AppTheme"
parent="android:style/Theme.Holo" ></style>
Run Code Online (Sandbox Code Playgroud)

它是在AndroidManifest.xml文件中为整个应用程序分配的:

<application
    android:theme="@style/AppTheme"
    [...]
Run Code Online (Sandbox Code Playgroud)

使用此样式,菜单如下所示:

在此输入图像描述

但是,如果我使用灯光主题:

<style name="AppTheme"
parent="android:style/Theme.Light" ></style>
Run Code Online (Sandbox Code Playgroud)

菜单将如下所示:

在此输入图像描述

我的问题是:

如何将HOLO主题应用于整个应用程序,并仅使用LIGHT主题菜单?

我只想应用LIGHT主题的对话框"style",并将HOLO主题应用于其他所有内容.

android android-menu android-theme

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

如何在Android中设置ActionaBar Tab文本的样式?

我正在使用ActionBarShrelock为预蜂窝设备提供操作栏.我在themes.xml文件中有以下代码...

 <style name="My.Tab.Style" parent="@android:style/Widget.TabWidget">
        <item name="android:textAppearance">@style/MyCustomTabTextStyle</item>
    </style>

   <style name="MyCustomTabTextStyle" parent="Widget.Sherlock.ActionBar.TabText">
        <item name="android:textAppearance">@android:style/TextAppearance.Medium</item>
        <item name="android:textSize">14sp</item>
        <item name="android:textStyle">bold</item>
        <item name="android:textColor">@color/tabbar_text_color</item>
    </style>
Run Code Online (Sandbox Code Playgroud)

比我用它作为

<item name="android:actionBarTabTextStyle">@style/My.Tab.Style</item>
<item name="actionBarTabTextStyle">@style/My.Tab.Style</item>
Run Code Online (Sandbox Code Playgroud)

任何人都可以解释为什么我在Tab的最后一个字母上有一些阴影吗?我怎么能摆脱它呢?PLZ帮助..我已经尝试了一切,但那个影子总是存在..

在此输入图像描述

android android-theme actionbarsherlock android-actionbar

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

从代码中显示标题栏

在清单文件中,我将此行添加到我的应用程序标记中

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

基本上每个活动都没有标题栏,但是对于我希望显示标题栏的其中一个活动

我知道要隐藏栏我可以使用此代码

this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Run Code Online (Sandbox Code Playgroud)

如何从代码中显示标题栏?

编辑 请不要高我怎么能隐藏标题栏:),我知道,如果有人知道我怎么能显示它?

我知道我可以把NoTitleBar放在我想要隐藏的每个活动中,我可以把它留给我想要展示的那个......但那不是我的观点

android titlebar android-titlebar android-theme android-activity

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

Android DatePickerDialog强调色(在v21 +中)

我正在为我的应用程序使用支持库21.我的主题也在值-v21中定义,但DatePickerDialog不使用强调颜色作为背景和文本颜色.

如何将此颜色更改为强调色?

我目前的themes.xml是

值/的themes.xml

<style name="AppTheme" parent="AppTheme.Base" />

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="windowActionModeOverlay">true</item>

    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)

值-V21 /的themes.xml

<style name="AppTheme" parent="AppTheme.Base">
    <item name="android:colorPrimary">@color/colorPrimary</item>
    <item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="android:colorAccent">@color/colorAccent</item>

    <item name="android:alertDialogTheme">@style/AppTheme.AlertDialog</item>
</style>

<style name="AppTheme.AlertDialog" parent="android:Theme.Material.Light.Dialog.Alert">
    <item name="android:colorPrimary">@color/colorPrimary</item>
    <item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="android:colorAccent">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)

android android-theme android-5.0-lollipop

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

无法在ActionBarActivity中创建alertDialog

我有一个Activity延伸ActionBarActivity.每当我尝试在其中创建一个时AlertDialog,就会在创建对话框的行中崩溃,从而产生此错误

java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
Run Code Online (Sandbox Code Playgroud)

但我已经在使用Appcompat主题,Theme.AppCompat.Light.NoActionBar因为我正在使用工具栏.这可能是什么原因?这是我的活动:

import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;



public class MyActivity extends ActionBarActivity {

    Toolbar toolbar;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_comments);

        toolbar = (Toolbar)findViewById(R.id.tool_bar_comment);
        setSupportActionBar(toolbar);
                AlertDialog alertDialog;
                alertDialog = new AlertDialog.Builder(getApplicationContext()).create();
                alertDialog.setTitle("Network error");
                alertDialog.setMessage("Check network connection and try again.");
                alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "ok", new DialogInterface.OnClickListener() { …
Run Code Online (Sandbox Code Playgroud)

android android-appcompat android-theme android-alertdialog android-actionbar-compat

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

将默认颜色设置为Android库

所以我有一个Android ,我希望其他人能够在使用它时轻松自定义其颜色.问题是颜色不仅仅是一个属性(如视图背景),但它更像是一个主题颜色(视图背景,文本颜色,按钮的笔触等)所以我是无法将其作为视图属性传递.所以我最终使用了a color reference并在样式,布局和drawable中使用它:

colors.xml:

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

layout.xml:

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="?attr/color">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="?attr/color"/>
    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:theme="@style/LibraryTheme.TextAppearance"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

库项目中的styles.xml:

<style name="LibraryTheme.TextAppearance">
    <item name="android:textColor">?attr/color</item>
    <item name="colorControlNormal">?attr/color</item>
    <item name="android:textColorHint">?attr/color</item>
    <item name="colorControlActivated">?attr/color</item>
    <item name="colorControlHighlight">?attr/color</item>
</style>
Run Code Online (Sandbox Code Playgroud)

这很有效,当有人使用我的lib时,他必须声明他希望你在他的主题中使用的颜色:

app项目中的styles.xml:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="color">@color/my_color</item>
</style>
Run Code Online (Sandbox Code Playgroud)

问题是这样的:我想用默认的配色方案来提供这个库.它现在可以通过2个选项执行:

  1. 使用默认颜色集声明我自己的主题,用户需要从我的主题继承他的主题.
  2. 在我的color.xml中放置一些default_color,以便用户可以将其用作主题中的颜色.

第一个非常糟糕,因为我不能强迫用户使用特定的应用主题(如AppCompact.Light).第二个也不是那么好,因为我希望用户能够无缝地使用默认值,并且我需要在主题中设置几种颜色.

有没有其他方式你认为我可以让其他用户轻松玩颜色?

谢谢.

android android-custom-view android-theme android-view android-custom-attributes

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

Android"您需要将Theme.AppCompat主题(或后代)与设计库一起使用"

好的,我得到这个错误(标题).很多帖子建议我(甚至安卓工作室)改变主题,到App.Appcompat,我已经做到了.

清单文件:

 <uses-permission android:name="android.permission.INTERNET" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/Theme.AppCompat">
    <activity
        android:name=".activity.MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".activity.ContactAcitivty"
        android:label="@string/activity_title_contact" />
    <activity
        android:name=".activity.CopyrightActivity"
        android:label="@string/activity_title_copyright" />
    <activity android:name=".activity.FormActivity">
            <intent-filter>
                <action android:name="info.androidhive.navigationdrawer.activity.FormActivity" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

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

Style.xml

    <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>
    </style>
    <style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay"  parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
Run Code Online (Sandbox Code Playgroud)

但仍然没有改变.

我不知道发生了什么,因为我以前没有遇到过这个问题(我没有在清单文件中添加App.compat)

Gradle:

compile …
Run Code Online (Sandbox Code Playgroud)

android android-appcompat android-layout android-theme

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

在Android M上,Gradient与IllegalArgumentException崩溃

在我的应用程序中,我使用渐变背景.我曾经在Lollipop手机上调试它,一切正常.今天我将我的手机(LG G4)更新为Marshmallow,现在当想要绘制渐变时,应用程序会崩溃并显示以下堆栈跟踪:

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.max.lucas, PID: 28163
                  java.lang.IllegalArgumentException: color and position arrays must be of equal length
                      at android.graphics.LinearGradient.<init>(LinearGradient.java:58)
                      at android.graphics.drawable.GradientDrawable.ensureValidRect(GradientDrawable.java:942)
                      at android.graphics.drawable.GradientDrawable.draw(GradientDrawable.java:516)
                      at android.view.View.getDrawableRenderNode(View.java:16451)
                      at android.view.View.drawBackground(View.java:16387)
                      at android.view.View.draw(View.java:16197)
                      at android.view.View.updateDisplayListIfDirty(View.java:15202)
                      at android.view.View.draw(View.java:15976)
                      at android.view.ViewGroup.drawChild(ViewGroup.java:3611)
                      at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3401)
                      at android.view.View.updateDisplayListIfDirty(View.java:15197)
                      at android.view.View.draw(View.java:15976)
                      at android.view.ViewGroup.drawChild(ViewGroup.java:3611)
                      at android.support.v7.widget.RecyclerView.drawChild(RecyclerView.java:3588)
                      at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3401)
                      at android.view.View.draw(View.java:16209)
                      at android.support.v7.widget.RecyclerView.draw(RecyclerView.java:3097)
                      at android.view.View.updateDisplayListIfDirty(View.java:15202)
                      at android.view.View.draw(View.java:15976)
                      at android.view.ViewGroup.drawChild(ViewGroup.java:3611)
                      at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3401)
                      at android.view.View.draw(View.java:16209)
                      at android.support.design.internal.ScrimInsetsFrameLayout.draw(ScrimInsetsFrameLayout.java:82)
                      at android.view.View.updateDisplayListIfDirty(View.java:15202)
                      at android.view.View.draw(View.java:15976)
                      at android.view.ViewGroup.drawChild(ViewGroup.java:3611)
                      at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1229)
                      at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3401)
                      at android.view.View.draw(View.java:16209)
                      at android.view.View.updateDisplayListIfDirty(View.java:15202) …
Run Code Online (Sandbox Code Playgroud)

android android-theme

6
推荐指数
1
解决办法
619
查看次数

如何在不影响其弹出菜单的情况下向微调器添加边框

我正在尝试为我的纺纱厂添加边框.

这是我到目前为止所做的:

在我的styles.xml中:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
      <!-- ... -->       
      <item name="android:spinnerItemStyle">@style/spinnerItemStyle</item>
      <!-- ... -->
</style>

<style name="spinnerItemStyle">
        <item name="android:padding">@dimen/form_horizontal_padding_normal</item>
        <item name="android:textAppearance">@style/TextAppearance.AppCompat.Subhead</item>
        <item name="android:background">@drawable/spinner_border</item>
        <item name="android:textColor">@color/secondary_text</item>
 </style>
Run Code Online (Sandbox Code Playgroud)

spinner_border.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <solid android:color="@android:color/white"/>
    <corners android:radius="6dp"/>
    <stroke
        android:width="1dp"
        android:color="@color/detail_accent_pane_background"/>

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

如果没有更改,弹出菜单的外观如下:

在此输入图像描述

更改后,微调器有边框

在此输入图像描述

但弹出菜单也有边框,这不是我想要的. 在此输入图像描述

如何在不影响弹出菜单的情况下为微调器添加边框?

谢谢.

android android-theme android-spinner

6
推荐指数
1
解决办法
7085
查看次数

谷歌地图主题

我已经在我的Android应用程序中实现了Google地图,一切看起来都很干净,直到几天.以前,地图看起来像下图

在此输入图像描述

现在,地图的外观与下图相似

在此输入图像描述 我没有在实现中更改或更新任何内容,但地图上有暗线,这使得难以阅读这些地方.

任何帮助表示赞赏.谢谢

注意:我已从Google下载图片以供参考,请忽略xml布局更改.

maps android google-maps android-theme

6
推荐指数
3
解决办法
534
查看次数