我正在尝试为appwidget定义一个主题,并将其应用于应用程序级别.我有一个主题,如,
<style name="theme.dark">
<item name="android"background">#000000</item>
</style>
Run Code Online (Sandbox Code Playgroud)
在我的清单中,我设置android:theme="@style/theme.dark"了应用程序.但是,当我运行appwidget时,它不会从样式中获取项目.我尝试style="@style/theme.dark"在我的视图布局中设置一个单独的元素,这确实有用......但这不是我想要的.我不想为我视图中的每个元素调出特定的style ="...".这一页,
http://www.androidengineer.com/2010/06/using-themes-in-android-applications.html
有一个很好的示例应用程序使用主题/样式,它的工作完美.唯一的区别是它是一个应用程序..它是在活动而不是应用程序上设置主题.
我还尝试在访问视图之前使用appwidget的onHandleUpdate()中的setTheme(...)以编程方式在Context对象上设置主题.这也不起作用.
有任何想法吗?谢谢.
我正在尝试在styles.xml中将背景颜色更改为黑色.背景变化很好但动作栏变脏了.actiobar背景的某些部分保持不变,而另一部分变为黑色.我不希望动作栏改变颜色.请帮忙
<style name="Theme.ApplicationTheme" parent="@style/Theme.Sherlock">
<item name="android:background">#000000</item> <!-- This line is changing the actionbar color -->
<item name="actionBarStyle">@style/Widget.MyTheme.ActionBar</item>
<item name="android:actionBarStyle">@style/Widget.MyTheme.ActionBar</item>
</style>
<style name="Widget.MyApplicationTheme.ActionBar" parent="Widget.Sherlock.ActionBar">
<item name="android:background">#2d2d2d</item>
<item name="background">#2d2d2d</item>
</style>
Run Code Online (Sandbox Code Playgroud) 我想做这样的事情:
<style name="cardViewInfo">
<item name="android:layout_marginLeft">@dimen/small_padding_card_view</item>
<item name="android:layout_marginRight">@dimen/small_padding_card_view</item>
<item name="android:layout_marginBottom">@dimen/small_padding_card_view</item>
<item name="android:layout_marginTop">@dimen/large_padding_card_view</item>
<item name="card_view:cardCornerRadius">2dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
但是我的名字card_view有问题没有定义,我的问题是我是否可以在布局上使用这个命名空间:
xmlns:card_view="http://schemas.android.com/apk/res-auto"
Run Code Online (Sandbox Code Playgroud)
最好的祝福.
我是移动开发的新手,我正在使用Xamarin工作室开发一个简单的应用程序,并在我的页面上添加了几个按钮.我注意到当我在模拟器(Android 5.0.1 - API 21)中运行时,所有按钮文本都出现在CAPITAL LETTERS中.
我已经关注为什么我的按钮文字被强制在Lollipop上的所有大写?并尝试添加<item name="android:textAllCaps">false</item>我的style.xml但它没有任何区别.
还检查为什么我的按钮文字强制在棒棒糖上的所有大写? 和Android 5.0(Lollipop)小部件按钮的文本都在全部大写.
如果我添加android:textAllCaps = "false"到我的所有按钮(在我的axml文件中)然后它将工作,但我想知道整个应用程序中的所有按钮的通用样式(甚至多种形式/活动)
任何人都可以建议在整个应用程序中使用某种样式的方法吗?
谢谢.
我观察到Android 6.0 Marshmallow中的新行为.滚动条的触摸区域比滚动条更干净.它在以下屏幕截图中可见.滚动条有20 dp(绿色区域),触摸区域可能是48 dp(蓝色和绿色区域).我想只在滚动条上方设置触摸区域:
我使用以下:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyTheme.Dark" parent="android:Theme.Black">
<item name="android:fastScrollStyle">@style/Widget.FastScroll</item>
<item name="android:scrollbarThumbVertical">@drawable/dark_scrollbar_thumb</item>
<item name="android:scrollbarTrackVertical">@drawable/dark_scrollbar_track</item>
<item name="android:scrollbarSize">4dp</item>
<item name="android:fastScrollThumbDrawable">@drawable/dark_scrollbar_fast_thumb</item>
<item name="android:fastScrollTrackDrawable">@drawable/dark_scrollbar_fast_track</item>
</style>
<style name="Widget.FastScroll" parent="android:Widget.Material.FastScroll">
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
dark_scrollbar_fast_thumb.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape>
<size
android:height="30dp"
android:width="20dp" />
<solid android:color="@android:color/transparent" />
</shape>
</item>
<item android:left="8dp" android:right="8dp">
<shape>
<size
android:height="30dp"
android:width="4dp" />
<solid android:color="@color/dark_secondary" />
</shape>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
dark_scrollbar_fast_track.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<size android:width="@dimen/1dp" />
<solid android:color="@color/dark_scrollbar_track" />
</shape>
Run Code Online (Sandbox Code Playgroud)
dark_scrollbar_fast_thumb.xml:
<item>
<shape>
<size
android:height="30dp" …Run Code Online (Sandbox Code Playgroud) 我想知道有没有办法定义或使用多个样式文件(Multiple, style.xml files)Android,而不是style.xml存在于res文件夹中的单个文件Application Project.目前我正在使用单一样式文件(style.xml).但style.xml由于我的许多自定义和自定义样式,文件的大小是巨大的.
我已经阅读了很多教程和示例,但所有那些提供网站甚至developer.android.com网站的教程和示例都显示了如何定义和使用Style但是,没有任何网站说是否有可能制作Multiple style.xml files单个style.xml文件以便大小文件可以减少.
任何帮助,将不胜感激...
我想让用户有机会选择颜色皮肤将有应用程序.例如,我应该使用具有不同色调的黑色皮肤以及具有色调的白色皮肤来实现黑色皮肤.
哪个是实现这一目标的最佳方法?
例如,我知道Android中有一个colors.xml文件,应该包含应用程序的颜色.是一种拥有两种颜色文件或某种东西的方法,并根据用户选择使用一种或另一种颜色?也许是styles.xml文件?
请告诉我您对实现这一目标的最佳方法的看法
谢谢
我的布局:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The main content view -->
<RelativeLayout
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.PagerTitleStrip
android:id="@+id/pager_title_strip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingTop="4dp"
android:paddingBottom="4dp"
style="@style/CustomPagerTitleStrip"/>
</android.support.v4.view.ViewPager>
</RelativeLayout>
<!-- The navigation drawer -->
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/drawer_header"
app:menu="@menu/drawer_menu"
style="@style/NavigationDrawerStyle"/>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
我的styles.xml文件:
<resources>
<style name="AppTheme" parent="Theme.AppCompat">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="actionBarTheme">@style/CustomActionBar</item>
<item name="android:textColor">@color/colorFontMenus</item>
<item name="itemTextColor">@color/colorFontMenus</item>
<item name="itemIconTint">@color/colorFontMenus</item>
</style>
<style name="CustomActionBar">
<!-- title text color -->
<item …Run Code Online (Sandbox Code Playgroud) 我试图根据按钮状态更改FAB中图标的图标颜色:
<android.support.design.widget.FloatingActionButton
android:id="@+id/search_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:tint="@color/add_button_tint"
android:src="@drawable/ic_add_black_24dp" />
Run Code Online (Sandbox Code Playgroud)
add_button_tint.xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true"
android:color="@color/white" />
<item android:color="@color/black"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
这在API> 23中效果很好,但是在旧版本的android中,它会引发异常.
这是我感到困惑的地方:
android:tint属性存在于支持FAB中,如果它只是一种颜色,即使在旧版本的android中也可以工作.IE这适用于我测试的所有版本:
android:tint="@color/black
Run Code Online (Sandbox Code Playgroud)
但是当我使用选择器时却没有.我究竟做错了什么?在旧版Android中,是否可以根据FAB的状态更改图标颜色?
android android-styles material-design floating-action-button
我想应用一些风格DatePicker.在平台中,attrs.xml我们可以看到以下属性DatePicker:
<declare-styleable name="DatePicker">
...
<!-- The text color for the selected date header text, ex. "2014" or
"Tue, Mar 18". This should be a color state list where the
activated state will be used when the year picker or day picker is
active.-->
<attr name="headerTextColor" format="color" />
<!-- The background for the selected date header. -->
<attr name="headerBackground" />
...
</declare-styleable>
Run Code Online (Sandbox Code Playgroud)
虽然我可以参考android:headerBackground,但出乎意料的是我无法为android:headerTextColor属性做到这一点.所以遵循以下代码styles.xml:
<style name="MyDatePickerStyle" parent="@android:style/Widget.Material.DatePicker">
<item name="android:headerBackground">@color/red</item> …Run Code Online (Sandbox Code Playgroud) android datepicker android-resources android-styles android-attributes
目前的答案没有帮助,这个问题没有答案
我创建了一个带有自定义视图的库,可以在创建时扩展布局.布局中的视图使用style="?attr/labelStyle"任何其他属性设置样式.
该属性被声明为库的attrs.xml:
<attr name="myViewStyle" format="reference"/>
<declare-styleable name="MyView">
<attr name="labelStyle" format="reference|color"/>
</declare-styleable>
Run Code Online (Sandbox Code Playgroud)
我在库中为此属性设置了一个默认值styles.xml:
<style name="MyViewStyle">
<item name="labelStyle">@style/LabelStyle</item>
</style>
<style name="LabelStyle">
<item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="...">...</item>
</style>
Run Code Online (Sandbox Code Playgroud)
最后在图书馆themes.xml:
<style name="MyViewStyleLight" parent="Theme.AppCompat.Light">
<item name="myViewStyle">@style/MyViewStyle</item>
</style>
Run Code Online (Sandbox Code Playgroud)
现在这是库的默认样式,但它在主项目中被覆盖 styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="myViewStyle">@style/MyViewStyleCustom</item>
</style>
<style name="MyViewStyleCustom" parent="MyViewStyleLight">
<item name="android:textColor">@color/gray</item>
<item name="...">...</item>
</style>
Run Code Online (Sandbox Code Playgroud)
自定义视图代码:
public MyView(Context context) {
this(context, null, R.attr.myViewStyle, 0);
}
public MyView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, R.attr.myViewStyle, 0);
}
public MyView(Context …Run Code Online (Sandbox Code Playgroud)