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
最满意答案
在Javascript(以及因此在Google Apps脚本中),只有在目标对象“拥有”该方法时才能调用方法。 您收到错误是因为您混淆了一些对象 - 对象类型不支持您正在使用的方法。 (同意Serge的评论!)
您遇到的错误是:
在第三行代码中,
dataLastRow = dataSheet.getLastRow()
产生一个Number,然后尝试dataLastRow.getRange()
。 但是,.getRange()
是一个Sheet
方法。之后,
destLastRow = destSheet.getLastRow()
产生另一个Number。 下一行有两个错误。 第一个是将此Number视为数组destLastRow[0]
。该行中的第二个错误是在未定义的值上调用
Range.setValue()
。 (它未定义,因为数组索引不正确。)在其下方,
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...
,您会看到以下内容:只要你输入
.
,编辑提供了一长串方法。 随着键入的字符越来越多,列表越来越短 - 此时您会看到各种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:
In the third line of code,
dataLastRow = dataSheet.getLastRow()
yields a Number, then you trydataLastRow.getRange()
. However,.getRange()
is aSheet
method.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]
.The second error in that line is invoking
Range.setValue()
on an undefined value. (It's undefined because the Array indexing is incorrect.)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...
: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 ofSheet.getRange()
methods.On the other hand, here's what happens when we type
var dataValues = dataLastRow.
: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.
相关问答
更多-
(这里使用评论的信息太多了。) VBA策划者Ron de Bruin写了一篇关于为什么xlCellTypeLastCell以及UsedRange可能在这里失败的文章: http : UsedRange 。 (在我在初始评论中链接到的帖子中, 在VBA中查找最后使用过的单元格时出错 ,以相同的方式描述了UsedRange的缺陷。) 这是直接引用: xlCellTypeLastCell和UsedRange可能存在的问题是: 最后一个单元格仅在您保存(或保存/关闭/重新打开文件)时重新设置。 如果更改了单元格格式 ...
-
如果Sheet2上有第二个表,那么您发布的表位于Sheet1上: =SUMIF(Sheet1!$B:$B, Sheet2!$A2, Sheet1!$D:$D) 如果周数列在A列中,则从A2开始,此公式将进入Sheet2的B2。 例如: A B 1 Week No. SUM 2 23 5795 3 24 6204 If you have the second table on Sheet2, and the one you ...
-
使用GAS将数据从工作表中的单元格移动到另一个工作表(Move data from cells in worksheet to another sheet using GAS)[2022-08-02]
在Javascript(以及因此在Google Apps脚本中),只有在目标对象“拥有”该方法时才能调用方法。 您收到错误是因为您混淆了一些对象 - 对象类型不支持您正在使用的方法。 (同意Serge的评论!) 您遇到的错误是: 在第三行代码中, dataLastRow = dataSheet.getLastRow()产生一个Number,然后尝试dataLastRow.getRange() 。 但是, .getRange()是一个Sheet方法。 之后, destLastRow = destSheet.g ... -
您可能需要修改此以适应您的需求,因为我不完全确定您的标准是什么,但这应该让您开始! 首先,创建一个名为“数据库”的表。 我假设你的复制范围是静态的。 如果范围不是静态的,您可以“取消注释”代码的“RCount”部分并修改以设置动态复制范围。 目前,代码将复制您的范围(B9:M20)并将其粘贴到Col A上最后一行中名为“数据库”的新表上。 要清除你的表格,我会在这个下面创建另一个宏(你可以只记录一个),标题为“Macro_Title”。 在“End Sub”之前 Call Macro_Title ...
-
尝试这个。 我得到了这个工作表: 工作表Sheet1 表2 应用以下代码: Private Sub Worksheet_Change(ByVal Target As Range) Dim nextRow As Long If Not Intersect(Target, Range("D:D")) Is Nothing Then If Not VBA.IsEmpty(Target) Or VBA.IsNull(Target) Then With Worksheets("Sheet2") ...
-
你可以试试这个: Sub Sample() With Sheets("Sheet1") Sheets("3").UsedRange.SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow.Copy .Cells(.Rows.Count, 1).End(xlUp).Offset(1) End With End sub You could try this: Sub Sample() With Sheets("She ...
-
使用基于其他工作表中的表格的单元格替换特定工作表的单元格(replace cells of a specific sheet with cells based on a table in other sheet)[2021-11-20]
您只需要使用以下代码替换myArray循环内的所有内容,以仅替换Data工作表中Range(A1:B10)中的Data For x = LBound(myArray, 1) To UBound(myArray, 2) Sheets("Data").Range("A1:B10").Replace What:=myArray(fndList, x), Replacement:=myArray(rplcList, x), _ LookAt:=xlPart, SearchOr ... -
将单元格移动到与目标相同的工作表时如何更新单元格引用?(How to update cell references when moving cells into same sheet as target?)[2023-04-14]
@凯尔的好主意。 对于那些无法强制更新单元格引用的人, TextToColumns可以正常工作。 但是,如果源范围为空,则TextToColumns一个错误,因此如果有任何可能,请使用不带任何操作的if语句跳过这些实例。 我成功的代码如下所示: Dim i As Integer For i = 1 To 1004 'Scans through row 2 from col A onwards 'If cell is empty, does nothing. 'If cell is not empty, ... -
如何将数据从一个工作表导入另一个工作表中的“仅一个单元格”(How to import data from one sheet to “only one cell” in another sheet)[2023-07-08]
授权访问外部电子表格后,请尝试 =JOIN(CHAR(10),QUERY(TRANSPOSE(IMPORTRANGE(spreadsheet_key,reference_string)),,2E6)) 如果源数据是 +---+----+----+ | | A | B | +---+----+----+ | 1 | A1 | B1 | | 2 | A2 | B2 | +---+----+----+ 结果将是 +---+---------+ | | A | +---+-------- ... -
将行移动到另一个工作表,其中单元格等于工作表名称(Move Row to another worksheet where cell equals worksheet name)[2022-04-06]
我将使用下一个: ActiveCell.EntireRow.Insert '在这种情况下插入一个新行[“匹配的行应始终复制到相应工作表的第2行,将现有数据连续移动”] Activecell.EntireRow.Copy '这将复制所有活动行。 ActiveCell.PasteSpecial '这会将数据粘贴到剪贴板中,确保此行位于复制行之后。 ActiveCell.EntireRow.Delete '使用此功能,您可以从包含MySQL数据源的工作表中删除数据。 根据这个,我认为你不需要订购数据,只需创建一个 ...