android 含义,android theme中的各个color的含义
今天测试了下colorPrimary、colorPrimaryDark、colorAccent、android:textColorPrimary、android:windowBackground这五个颜色的含义。Activity页面代码:public class Test2AC extends AppCompatActivity {@Overrideprotected void onCreate(
今天测试了下colorPrimary、colorPrimaryDark、colorAccent、android:textColorPrimary、android:windowBackground这五个颜色的含义。Activity页面代码:
public class Test2AC extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ac_test2);
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setTitle(R.string.app_name);
}
}
在androidmanifest中注册:
android:name=".activity.Test2AC"
android:screenOrientation="portrait"
android:theme="@style/AppBaseThemeF">
所使用的Theme样式:
@color/colorPrimary
@color/colorPrimaryDark
@color/colorAccent
@color/textColorPrimary
@color/windowbg
每个颜色值如图:
页面布局:R.layout.ac_test2
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:background="@color/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:layout_height="wrap_content">
android:layout_width="match_parent"
android:height="60dp"
android:text="FFFFFFFFFFFFFFFFffff"
android:layout_height="wrap_content"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_width="wrap_content"
android:orientation="horizontal"
android:layout_height="wrap_content">
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
最终效果图:
由于页面Activity是根Activity,系统会自带一个ToolBar。上面的ToolBar的title颜色是白色的,而下面的ToolBar的title颜色是textColorPrimary定义的颜色,上面的ToolBar是系统的,如果使用样式Theme.AppCompat.Light.DarkActionBar,那么title颜色就是白色,如果使用样式Theme.AppCompat.Light,那么title颜色就是textColorPrimary定义的颜色。
如果不调用getWindow().setStatusBarColor(int color);方法的话,那么状态栏的颜色就是colorPrimaryDark定义的颜色。
当然还有其他很多的颜色,没有一一实验,大致总结下:
navigationBarColor:导航栏颜色
colorControlNormal:组件的默认颜色 (比如CheckBox, RadioButton).
colorBackground:页面或者组件的背景颜色(比如 activity背景色)
colorForeground:前景色
textColorLink:links/href的颜色
android:textColorHint:提示颜色
android:textColorSecondary:图片标题或者字幕、Medium、action bar subtitle等。
textColorTertiary:不经常用,按字面意思是第三级颜色,参照第二级颜色textColorSecondary
color大全可以参考文献2.
参考:
更多推荐
所有评论(0)