我试图通过设置TextView.setLineSpacing()的负“添加”来减少TextView中的行间距.除了底线被截断之外,它运行良好.

主要布局

android:id="@+id/text_view"

android:padding="dp"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_centerHorizontal="true"

android:layout_centerVertical="true"

tools:context=".MainActivity" />

主要活动:(注意

package com.font_test;

import android.app.Activity;

import android.graphics.Typeface;

import android.os.Bundle;

import android.widget.TextView;

public class MainActivity extends Activity {

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

final Typeface typeface = Typeface.createFromAsset(getAssets(),"fonts/custom_fonts.ttf");

final TextView tv = (TextView) findViewById(R.id.text_view);

tv.setTypeface(typeface);

tv.setTextSize(60);

tv.setLineSpacing(-30f,1f); // *** -30 to reduce line spacing

tv.setBackgroundColor(0x280000ff);

tv.setText("gggkiiikkk" + "\n" + "gikgikgik" + "\n" + "kigkigkig");

}

}

这导致在视图底部截断(注意底线的’g’):

似乎问题与错误的布局测量有关.如果我将TextView设置为

android:layout_height="fill_parent"

它确实正确呈现:

知道怎么解决吗?如果它有帮助,我不介意有丑陋的变通方法.我也可以访问FontForge,如果需要我可以修改字体文件.

android button 行间距,android – 如何减少TextView行间距相关推荐

  1. android 计算行间距,android – 如何减少TextView行间距

    我试图通过设置TextView.setLineSpacing()的负"添加"来减少TextView中的行间距.除了底线被截断之外,它运行良好. 主要布局 android:id=&q ...

  2. kotlin button_使用Kotlin和XML的Android Button

    kotlin button In this tutorial, we'll learn how to create a Button in Android apps using Kotlin prog ...

  3. Android Button 属性介绍与使用

    一.简介 Button 控件继承 TextView,拥有 TextView 的属性. StateListDrawable 是 Drawable 资源的一种,可以根据不同的状态,设置不同的图片效果,关键 ...

  4. android radiogroup清空,android RadioGroup的使用方法

    创建一个MainActivity.java的主类 android:layout_width="fill_parent" android:layout_height="fi ...

  5. Android商城排版,android排版布局学习

    Android开发学习之路--UI之基本布局 android使用shape stroke描边只保留底部 RadioGroup的使用 一.项目粮仓 粮仓学习: liangcang: 启动页面:act_s ...

  6. android中段落距离,Android中TextView 行间距和段间距设置

    这里有一篇文章关于设置段落间距(仅供参考):https://blog.csdn.net/yingpaixiaochuan/article/details/77996793 TextView行间距设置 ...

  7. Android中TextView 行间距和段间距设置

    这里有一篇文章关于设置段落间距(仅供参考):https://blog.csdn.net/yingpaixiaochuan/article/details/77996793 TextView行间距设置 ...

  8. Android TextView行间距解析

    TextView行间距设置 在布局XML中有两个参数可以对TextView的行间距进行设置. 分别为:Android:lineSpacingExtra 和 android:lineSpacingMul ...

  9. Android中的基础控件TextView、Button、ImageView、EditText、ProgressBar

    文章目录 1 Android中的基础控件 1.1 控件的通用属性 2 TextView 2.1 TextView的继承关系 2.2 TextView的常用属性 3 EditText 3.1 常用属性 ...

最新文章

  1. 如何使用Azure ML Studio开启机器学习
  2. 热议:这样的开源项目,你会支持吗?
  3. saltstack (1) 简介
  4. Eclipse的JQuery提示插件-Spket(别试了,没什么效果,且安装设置麻烦)
  5. java 中对象引用,以及对象赋值
  6. python赋值浅拷贝和深拷贝的区别_浅拷贝、深拷贝和普通赋值操作有什么区别?...
  7. Spring Boot之发送HTTP请求(RestTemplate详解)
  8. CF285D.Permutation Sum
  9. linux管道和tee命令
  10. caffe android lib
  11. DSP实验二c语言程序,实验1.2:编写一个以C语言为基础的DSP程序
  12. C++中读写文件demo
  13. python处理Excel数据串行串列问题
  14. 云服务器搭网站需要买域名吗,买了云服务器还要买域名吗
  15. java 地铁线路_个人项目-地铁出行路线规划(Java代码实现)
  16. 如何自制虚拟直播,在里分享3种方法,总有一个你喜欢
  17. Ubuntu16.04无法连接Wifi解决方案 (绝对有效)
  18. PDF可以通过OCR图文识别软件转换为JPEG图像吗
  19. 数学类笔试题(四分位数、数据规约和协方差)
  20. 在VS中添加lib的三种方法

热门文章

  1. Base64 编解码
  2. jQuery与Ajax的应用——《锋利的jQuery》(第2版)读书笔记3
  3. LeetCode Palindrome Partitioning II
  4. codeforces 297 E. Anya and Cubes
  5. Javascript实现最简跨平台面向对象拖拽
  6. 新云网站管理系统最新版注入漏洞
  7. 微软重拳出击:盗版 Windows 将无处遁形!
  8. 终于有人把自然语言处理、机器学习、深度学习和AI讲明白了
  9. 不要等到离职,才明白这些道理
  10. IDEA优雅整合Maven+SSM框架(详细思路+附带源码)