android textview字体加粗 Android studio最新水平居中和垂直居中

Android中字体加粗
在xml文件中使用android:textStyle=”bold”
但是不能将中文设置成粗体,将中文设置成粗体的方法是:
TextView tv = (TextView)findViewById(R.id.TextView01);
TextPaint tp = tv.getPaint();
tp.setFakeBoldText(true);
取消加粗效果设置:
TextPaint tp = tv.getPaint();
tp.setFakeBoldText(false);
方法二:
textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));//加粗
-------------
android textview 垂直居中

LinearLayout分为水平分布、垂直分布:
android:orientation="vertical" //垂直分布
android:orientation="horizontal" //居中分布
<LinearLayout  
// 下面gravity属性的参数:center为居中,center_horizontal为水平居中,center_vertical为垂直居中
android:gravity="center|center_horizontal|center_vertical" >

注:android:gravity和android:layout_gravity的区别在于前者对控件内部操作,后者是对整个控件操作。
例如:android:gravity="center"是对textView中文字居中
android:layout_gravity="center"是对textview控件在整个布局中居中
出现"layout"就是控件对整个布局的操作。

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center|center_horizontal|center_vertical" >
// 上面gravity属性的参数:center为居中,center_horizontal为水平居中,center_vertical为垂直居中
</LinearLayout>
注意:android:layout_width="fill_parent" android:layout_height="fill_parent" 属性中,若水平居中,至少在宽度上占全屏;若垂直居中,则在高度上占全屏

RelativeLayout布局下的居中:
<RelativeLayout xmlns:Android="http://schemas.android.com/apk/res/android"  
    Android:layout_width="match_parent" Android:layout_height="match_parent">  
  
    <Button Android:id="@+id/btnxx" Android:layout_width="wrap_content"  
        Android:layout_height="wrap_content" Android:gravity="center_horizontal"
        Android:textSize="20sp" Android:layout_alignParentBottom="true"  
        Android:layout_centerHorizontal="true" Android:text="back" />  
</RelativeLayout>

Android:gravity="CENTER_VERTICAL":这个是垂直居中对齐
Android:gravity="BOTTOM":放在容器的底部
Android:gravity="CENTER" :放在容器的中心

android textview字体加粗 Android studio最新水平居中和垂直居中的更多相关文章

  1. android TabLayout设置选中标签字体加粗功能

    实现 TabLayout 选中tab标签字体加粗功能如下: xml文件中定义: <android.support.design.widget.TabLayout android:id=" ...

  2. html小知识点汇总(浏览器导航上显示图标、div无高度时试着清除浮动、文字环绕图片、字体加粗、div按百分比分、已有的不合适的class,针对特定的标签进行修改)

    1.新点击的网页,在浏览器导航上显示图标: 像这种效果: <head> <meta charset="UTF-8"> <meta name=" ...

  3. html字体加粗标签与写法

    在html中字体加粗的标签为<b>标签,当我们使用了该标签,字体就会加粗,一般用于注明重要信息,强调文字上面写法如下 字体加粗:<b>这里的字体就会加粗</b> 效 ...

  4. HTML怎么实现字体加粗

    HTML的加粗标签是<b>标签,是用来对你自定文字加粗,写法如下: 字体加粗:<b>这里是加粗的内容</b> 这样就可以实现加粗了!

  5. android TextView Unicde编码转换 android中一些特殊字符Unicode码值

    android TextView Unicde编码转换 android中一些特殊字符Unicode码值 android中一些特殊字符(如:←↑→↓等箭头符号,约等于号≍)的Unicode码值 Text ...

  6. Android TextView中 字体加粗方法

    textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));//加粗 textView.getPaint().setFakeBoldT ...

  7. html 字体加粗

    <font style="font-weight: bold;">无敌小昆虫</font> <font>无敌小昆虫</font> f ...

  8. IPHONE 字体加粗

    UIFONT 没有字体加精参数,但可以修发,字体名,达到加粗的效果正常:Helvetica加粗"Helvetica-Bold""TimesNewRomanPS-BoldM ...

  9. UILabel字体加粗等属性和特效

    /* Accessing the Text Attributes text  property font  property textColor  property textAlignment  pr ...

随机推荐

  1. Spring事务管理详解_基本原理_事务管理方式

    1. 事务的基本原理 Spring事务的本质其实就是数据库对事务的支持,使用JDBC的事务管理机制,就是利用java.sql.Connection对象完成对事务的提交,那在没有Spring帮我们管理事 ...

  2. python 遇到的问题及解答

    1.使用pip安装python 模块 打开cmd 输入pip install *,如pip install numpy    等待安装(如下) C:\WINDOWS\System32>pip i ...

  3. centos7安装webmin

    安装webmin准备centos7系统1.下载http://download.webmin.com/download/yum/选择:webmin-1.700-1.noarch.rpm 安装包 wget ...

  4. sql server外网复制+非默认端口

    注意查看服务器名称,这出来的是什么,就必须要在别名上写什么,如果不一样,请参照 :修改计算机名 SELECT @@SERVERNAME as InstalledName, SERVERPROPERTY ...

  5. centos安装Django之三:安装python

    这是centos安装Django系列第三篇,安装python.centos系统已经自带了python2.6,但是它被系统很多程序所依赖,不建议删除.我们可以使用以下命令来查看我们使用的Python版本 ...

  6. centos6.8上yum安装zabbix3.2

    centos6.8上yum安装zabbix3.2 zabbix3.2安装文档:https://www.zabbix.com/documentation/3.2/manual/installation/ ...

  7. Spark Sql之ThriftServer和Beeline的使用

    概述 ThriftServer相当于service层,而ThriftServer通过Beeline来连接数据库.客户端用于连接JDBC的Server的一个工具 步骤 1:启动metastore服务 . ...

  8. Go包管理工具Vendor使用

    一.Go包管理工具Vendor 一.使用步骤 1.首先,从go get -u github.com/kardianos/govendor下载govendor工具到本地. 2.govendor使用时,必 ...

  9. div+CSS实现页面的布局要点记录

    1.页面任何控件可以通过div包装为一个模块,然后通过margin(外补丁)和padding(内补丁)对控件位置的摆放进行控制,以实现想要的效果. 2.position:absolute;对控件实现绝 ...

  10. js 图片区域可点击,适配移动端,图片大小随意改变

    实现图片区域可点击,实际上使用map是可以的,但是适配效果并不好,图片只能是固定大小的值,而且点都被写死了. 在这里,我使用的js基于canvas写的一个小工具.可以圈出你需要点击的部分,然后生成一串 ...