当前位置: 首页 > news >正文

网站 网络架构溧阳企业网站建设价格

网站 网络架构,溧阳企业网站建设价格,各大网站网络推广的收费,2019做网站seo行不行Android应用开发学习笔记——目录索引 本章介绍文本视图#xff08;TextView#xff09;的显示#xff0c;包括#xff1a;设置文本内容、设置文本大小、设置文本显示颜色。 一、设置TextView显示内容 Layout XML文件中设置 如#xff1a;res/layout/activity_main.xm… Android应用开发学习笔记——目录索引 本章介绍文本视图TextView的显示包括设置文本内容、设置文本大小、设置文本显示颜色。 一、设置TextView显示内容 Layout XML文件中设置 如res/layout/activity_main.xml中通过属性 android:text 设置文本 TextViewandroid:idid/textViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textHello World! Java 代码中设置 调用文本视图的setText()方法设置 TextView textView (TextView) findViewById(R.id.textView); textView.setText(Hello World!); strings.xml中设置 Android Studio不推荐在xml布局文件直接Hardcoded string 推荐在/res/values目录strings.xml文件添加然后使用string引用 resourcesstring nameapp_nameTextView/stringstring nametextView_helloHello World!/string /resources res/layout/activity_main.xml TextViewandroid:idid/textViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textstring/textView_hello java代码中 TextView textView (TextView) findViewById(R.id.textView); textView.setText(R.string.textView_hello); layout XML或者java代码中都从string.xml引用字符串资源以后要显示其他内容也只需要修改string.xml一个地方即可Android Studio推荐使用这种方法。 二、设置TextView显示大小 Layout.xml文件中设置 android:textSize设置文本大小 TextViewandroid:idid/textViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textSize30sp 发现输入数字中有一个下来列表 sp专门用来设置字体大小和系统设置中字体大小相关跟随系统字体一起变化 px像素屏幕的最小显示单位 pt磅1/72英寸 mm毫米 in英寸1英寸 2.54厘米 25.4毫米 dp与设备无关的显示单位有时也写作dip 其中常用的是px、dp和sp三种。 dp和px的转换 int dip2px(Context context, float dp) {float scale context.getResources().getDisplayMetrics().density;return (int) (dp * scale 0.5f); } int px2dip(Context context, int px) {float scale context.getResources().getDisplayMetrics().density;return (int) (px / scale 0.5f); } Java 代码中设置 调用文本视图的setTextSize()方法设置 TextView textView (TextView) findViewById(R.id.textView); textView.setTextSize(30); setTextSize()使用的是spCOMPLEX_UNIT_SP public void setTextSize(float size) {setTextSize(TypedValue.COMPLEX_UNIT_SP, size);} 手机【设置】菜单-【显示】-【字体与显示大小】调整字体大小可以看到使用sp文本字体大小会跟随系统变化使用dp的不会变化。 三、设置TextView显示颜色 Layout.xml文件中设置 android:textColor设置文本大小 XML 中android:textColor默认是不透明也就是alpha 0xFF,在前面要加“#”后面是十六进制RGB TextViewandroid:idid/textViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textSize30spandroid:textstring/textView_helloandroid:textColor#FF0000 Java 代码中设置 调用文本视图的setTextColor()方法设置 Java代码中默认是透明也就是alpha 0x00,格式为ARGB使用十六进制0x开头 如红色0xFFFF0000、绿色0xFF00FF00、蓝色0xFF0000FF、白色0xFFFFFFFF TextView textView (TextView) findViewById(R.id.textView); textView.setTextColor(0xFFFF0000); Color类中定义了12中颜色可以使用 Color类定义 值 说明 Color类定义 值 说明 BLACK 0xFF000000 黑色 GREEN 0xFF00FF00 绿色 DKGRAY 0xFF444444 深灰 BLUE 0xFF0000FF 蓝色 GRAY 0xFF888888 灰色 YELLOW 0xFFFFFF00 黄色 LTGRAY 0xFFCCCCCC 浅色 CYAN 0xFF00FFFF 青色 WHITE 0xFFFFFFFF 白色 MAGENTA 0xFFFF00FF 品红 RED 0xFFFF0000 红色 TRANSPARENT 0 透明 TextView textView (TextView) findViewById(R.id.textView); textView.setTextColor(Color.BLUE); colors.xml中设置 /res/values目录colors.xml文件添加 ?xml version1.0 encodingutf-8? resourcescolor namepurple_200#FFBB86FC/colorcolor namepurple_500#FF6200EE/colorcolor namepurple_700#FF3700B3/colorcolor nameteal_200#FF03DAC5/colorcolor nameteal_700#FF018786/colorcolor nameblack#FF000000/colorcolor namewhite#FFFFFFFF/color /resources res/layout/activity_main.xml引用color/自定义颜色名称 TextViewandroid:idid/textViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textstring/textView_helloandroid:textColorcolor/purple_200 java代码中引用R.color.颜色 TextView textView (TextView) findViewById(R.id.textView); textView.setTextColor(R.color.purple_200); 设置背景颜色 Layout XML文件中android:background设置背景 TextViewandroid:idid/textViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textstring/textView_helloandroid:textColorcolor/purple_200android:background#111111 java代码中 setBackgroundColor()参数使用Color类或者十六进制 TextView textView (TextView) findViewById(R.id.textView); textView.setBackgroundColor(Color.BLUE); // 或者 textView.setBackgroundColor(0xFF0000FF); setBackgroundResource() 参数R.color.颜色R.drawable. TextView textView (TextView) findViewById(R.id.textView); textView.setBackgroundResource(R.color.black); 注意 XML属性android:background和Java方法 setBackgroundResource()用来设置控件的背景不单背景颜色还可以使用图片背景。图片放到/res/drawableXML中引用方法drawable/ TextViewandroid:idid/textViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textstring/textView_helloandroid:backgrounddrawable/ic_launcher_background java 代码使用R.drawable. TextView textView (TextView) findViewById(R.id.textView); textView.setBackgroundResource(R.drawable.ic_launcher_background); 四、TextView控件测试程序 java MainActivity.java 源码 百度网盘链接:百度网盘 请输入提取码 提取码:test 点此查看Android应用开发学习笔记的完整目录
http://www.dnsts.com.cn/news/210938.html

相关文章:

  • 网站开发如可使用支付宝深圳石岩做网站的公司
  • 合肥网页网站制作定制型营销网站建设
  • 网站怎样投放广告位有什么做任务的网站
  • 培训网站 建研究思路 网站建设
  • 网站开发组岗位石家庄做网站哪家公司好
  • 无锡建设主管部门网站欧铂丽全屋定制价格每平米多少钱
  • 苏州智能网站开发找山东制作app公司
  • 北京网站开发哪家好薇营销导向的网站建设的主要流程
  • 小网站推荐wordpress漫画商城
  • 枣庄机关建设网站外贸管理软件免费
  • 百度地图添加到网站网页设计html代码大全明星
  • 南郊做网站wordpress在线扫描
  • 黑龙江网站建设业务手机百度下载免费
  • 颍上县住房和城乡建设局网站如何用Python网站开发
  • 购物网站的建设如何再网站上做免费广告
  • 湖南企业建网站公司久久建筑网如何获取积分
  • 主机屋 大网站wordpress主题文件夹在
  • 广州网站快速制作网络seo公司
  • 好的空间网站汕头个人网站建设
  • 网站建设网站维护网站外包广州去东莞回来要隔离吗
  • 织梦教育咨询企业网站模板wordpress 汉化模板
  • 做兼职调查哪个网站好网站制作 常见问题
  • 网站设计好网站百度信息流推广技巧
  • 做网站的公司经营范围怎么写商城网站建设都有哪些类型
  • 网站建设需要的模块财务软件哪里买
  • 有免费建站的网站产品网站更新内容
  • 做下载网站赚钱建筑电工证查询网站
  • 外贸网站高端定做化妆品 网站建设案例
  • 外贸网站建设制作做网络传销网站犯罪吗
  • 温州做网站报价合肥瑶海区房价