android 含义,android theme中的各个color的含义

今天测试了下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

每个颜色值如图:

a1713437da52

页面布局: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"/>

最终效果图:

a1713437da52

由于页面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
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值