首页 \ 问答 \ LG设备上的字体大小太大(Font Size too big on LG device)

LG设备上的字体大小太大(Font Size too big on LG device)

我有一个完全适合mdpi平板电脑的布局。 但是,当我在我的hdpi LG平板电脑上运行应用程序时,字体变得比预期的要大。

我如何缩放布局并设置文本大小的示例:

        int nameTvHeight = (int)ConvertDpToPix (heightScale  * 11);
        LinearLayout.LayoutParams p2 = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.WrapContent,nameTvHeight);
        p2.Gravity = GravityFlags.CenterHorizontal;
        nameTv.LayoutParameters = p2;
        nameTv.TextSize = nameTvHeight;
        nameTv.SetIncludeFontPadding (false);

在LG平板电脑上,看起来字体大于文本视图的高度,因此它在底部被切断。 任何人都可以指出原因和/或解决方案吗?

此外,设置中的fontsize设置为normal,字体本身就像roboto一样默认的android字体。 平板电脑有Android 4.2.2版


I have a layout that fits perfectly on mdpi tablets. However, when i run the application on my hdpi LG tablet, the font gets bigger than it supposed to be.

an example of how i scale my layout and set the textsize:

        int nameTvHeight = (int)ConvertDpToPix (heightScale  * 11);
        LinearLayout.LayoutParams p2 = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.WrapContent,nameTvHeight);
        p2.Gravity = GravityFlags.CenterHorizontal;
        nameTv.LayoutParameters = p2;
        nameTv.TextSize = nameTvHeight;
        nameTv.SetIncludeFontPadding (false);

On the LG tablet, it looks like the fontsize is bigger than the height of the textview, so it gets cut off at the bottom. Can anyone point out the reasons and/or the solutions to this?

Also, the fontsize in the settings is set on normal, and the font itself is roboto like the default android typeface. The tablet has Android version 4.2.2


原文:https://stackoverflow.com/questions/29939929
更新时间:2023-06-24 06:06

最满意答案

在Javascript(以及因此在Google Apps脚本中),只有在目标对象“拥有”该方法时才能调用方法。 您收到错误是因为您混淆了一些对象 - 对象类型不支持您正在使用的方法。 (同意Serge的评论!)

您遇到的错误是:

  1. 在第三行代码中, dataLastRow = dataSheet.getLastRow()产生一个Number,然后尝试dataLastRow.getRange() 。 但是, .getRange()是一个Sheet方法。

  2. 之后, destLastRow = destSheet.getLastRow()产生另一个Number。 下一行有两个错误。 第一个是将此Number视为数组destLastRow[0]

  3. 该行中的第二个错误是在未定义的值上调用Range.setValue() 。 (它未定义,因为数组索引不正确。)

  4. 在其下方, var ID = destLastRow[1]重复错误#2。

此编辑版本删除了这些错误。 它可能在逻辑上有其他错误,它肯定不完整,但它运行。 添加了注释以显示每个语句返回的对象类型。

function sendData() {

  var sourceSS = SpreadsheetApp.getActiveSpreadsheet();      //= Spreadsheet
  var dataSheet = sourceSS.getSheetByName("Data");           //= Sheet
  var dataLastRow = dataSheet.getLastRow();                  //= Number
  var dataValues = dataSheet.getRange("A"+(dataLastRow)+":G"+(dataLastRow)).getValues();
                                                             //= Array [[]]

  var emailSheet = sourceSS.getSheetByName('Emails');        //= Sheet
  var recipient = emailSheet.getRange('B2:B22').getValues(); //= Array [[]]
  var orgUnit = emailSheet.getRange('A2:A22').getValues();   //= Array [[]]

  var destSS = SpreadsheetApp.openById('SHEETID');           //= Spreadsheet
  var destSheet = destSS.getSheetByName('Sheet1');           //= Sheet
  var destLastRow = destSheet.getLastRow();                  //= Number
  var type = destSheet.getRange(destLastRow, 0);             //= Range
  type.setValue('NEW');                                      //= Range (for chaining)
  var ID = destSheet.getRange(destLastRow, 1);               //= Range

}

自动填充作为缺陷清除工具

在这种情况下,Apps脚本编辑器的自动完成功能是您的朋友。 当编辑器能够确定您正在处理的对象类型时,它将提供支持的方法列表。 如果您开始输入var dataValues = dataSheet.getR... ,您会看到以下内容:

截图w自动完成

只要你输入. ,编辑提供了一长串方法。 随着键入的字符越来越多,列表越来越短 - 此时您会看到各种Sheet.getRange()方法。

另一方面,这是当我们输入var dataValues = dataLastRow.时会发生什么var dataValues = dataLastRow.

在此处输入图像描述

不多。 编辑器没有为此类型提供的自动完成方法Number 。 如果您在编辑时调整了此行为,则可以避免许多以后可能具有高PITA因子的简单错误。


In Javascript (and therefore in Google Apps Script), a method can only be invoked if the target object "has" that method. You're getting errors because you've mixed up some of your objects - the object types don't support the methods that you're using. (Agreeing with Serge's comment!)

The errors you have are:

  1. In the third line of code, dataLastRow = dataSheet.getLastRow() yields a Number, then you try dataLastRow.getRange(). However, .getRange() is a Sheet method.

  2. Later, destLastRow = destSheet.getLastRow() yields another Number. The next line has two errors. The first is that this Number is treated as an Array, destLastRow[0].

  3. The second error in that line is invoking Range.setValue() on an undefined value. (It's undefined because the Array indexing is incorrect.)

  4. Just below that, var ID = destLastRow[1] repeats error #2.

This edited version removes those errors. It may have other errors in logic, and it's certainly not complete, but it runs. Comments have been added to show what object types are returned with each statement.

function sendData() {

  var sourceSS = SpreadsheetApp.getActiveSpreadsheet();      //= Spreadsheet
  var dataSheet = sourceSS.getSheetByName("Data");           //= Sheet
  var dataLastRow = dataSheet.getLastRow();                  //= Number
  var dataValues = dataSheet.getRange("A"+(dataLastRow)+":G"+(dataLastRow)).getValues();
                                                             //= Array [[]]

  var emailSheet = sourceSS.getSheetByName('Emails');        //= Sheet
  var recipient = emailSheet.getRange('B2:B22').getValues(); //= Array [[]]
  var orgUnit = emailSheet.getRange('A2:A22').getValues();   //= Array [[]]

  var destSS = SpreadsheetApp.openById('SHEETID');           //= Spreadsheet
  var destSheet = destSS.getSheetByName('Sheet1');           //= Sheet
  var destLastRow = destSheet.getLastRow();                  //= Number
  var type = destSheet.getRange(destLastRow, 0);             //= Range
  type.setValue('NEW');                                      //= Range (for chaining)
  var ID = destSheet.getRange(destLastRow, 1);               //= Range

}

Autocomplete as a defect removal tool

In this situation, the Autocomplete feature of the Apps Script Editor is your friend. When the editor is able to determine what object type you're dealing with, it will offer a list of supported methods. Here's what you see if you start typing var dataValues = dataSheet.getR...:

Screenshot w autocompletion

As soon as you typed ., the editor offered up a long list of methods. As more characters were typed, the list got shorter - and at this point you see a variety of Sheet.getRange() methods.

On the other hand, here's what happens when we type var dataValues = dataLastRow.:

enter image description here

Not much. The editor has no autocomplete methods to offer for this type, Number. If you're tuned in to this behavior as you edit, you can avoid many simple mistakes that can have a high PITA factor later.

相关问答

更多

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)