android中谷歌文档预览中的RTL问题
当我试图在谷歌文档中从右向左创建一个文本时,当有人不登录时,它在每个android浏览器中的预览都是不正常的。我的意思是Android浏览器仍然以从左到右的格式显示它。 当然,在登录后,或者在使用谷歌文档Android应用程序时,都不存在这样的问题。 有没有解决这个问题的方法,比如使用谷歌应用程序脚本之类的 我尝试了一些朋友建议的代码,但它不能正常工作android中谷歌文档预览中的RTL问题,android,google-apps-script,Android,Google Apps Script,当我试图在谷歌文档中从右向左创建一个文本时,当有人不登录时,它在每个android浏览器中的预览都是不正常的。我的意思是Android浏览器仍然以从左到右的格式显示它。 当然,在登录后,或者在使用谷歌文档Android应用程序时,都不存在这样的问题。 有没有解决这个问题的方法,比如使用谷歌应用程序脚本之类的 我尝试了一些朋友建议的代码,但它不能正常工作 function makeRight(){ var body =DocumentApp.getActiveDocument().getB
function makeRight(){
var body =DocumentApp.getActiveDocument().getBody();
console.log("HERE BM!")
//var paraghraphs = DocumentApp.getActiveDocument().getBody().findElement(DocumentApp.ElementType.PARAGRAPH);
for (var i = 0; i < body.length; i++){
var ithchild = body.getChild(i)
if (ithchild.getType() == DocumentApp.ElementType.PARAGRAPH){
ithchild.setAlignment(DocumentApp.HorizontalAlignment.RIGHT);
}
}
}
函数makeRight(){
var body=DocumentApp.getActiveDocument().getBody();
log(“这里是BM!”)
//var paragraphs=DocumentApp.getActiveDocument().getBody().findElement(DocumentApp.ElementType.段落);
对于(变量i=0;i
看起来您正试图在body.length上运行for语句,但这并没有返回数字,因此for语句甚至没有运行
我接受了你的代码并做了一些更改,然后在我自己的Google文档上进行了测试,下面的代码似乎如你所期望的那样工作
function makeRight() {
var body = DocumentApp.getActiveDocument().getBody();
var numChildren = body.getNumChildren(); //gets number of children for body
//for each child of body, run the below code
for (var i = 0; i < numChildren; i++) {
var ithchild = body.getChild(i).asParagraph();
if (ithchild.getType() == DocumentApp.ElementType.PARAGRAPH) {
ithchild.setAlignment(DocumentApp.HorizontalAlignment.RIGHT);
}
}
}
您还需要将变量“ITHCILD”作为一个段落,这就是为什么我在该行中添加了aspagraph():
var ithchild = body.getChild(i).asParagraph();
然后可以使用该命令在整个文档上运行for语句:
for (var i = 0; i < numChildren; i++) {
for(变量i=0;i
看起来您正试图在body.length上运行for语句,但这并没有返回数字,因此for语句甚至没有运行
我接受了你的代码并做了一些更改,然后在我自己的Google文档上进行了测试,下面的代码似乎如你所期望的那样工作
function makeRight() {
var body = DocumentApp.getActiveDocument().getBody();
var numChildren = body.getNumChildren(); //gets number of children for body
//for each child of body, run the below code
for (var i = 0; i < numChildren; i++) {
var ithchild = body.getChild(i).asParagraph();
if (ithchild.getType() == DocumentApp.ElementType.PARAGRAPH) {
ithchild.setAlignment(DocumentApp.HorizontalAlignment.RIGHT);
}
}
}
您还需要将变量“ITHCILD”作为一个段落,这就是为什么我在该行中添加了aspagraph():
var ithchild = body.getChild(i).asParagraph();
然后可以使用该命令在整个文档上运行for语句:
for (var i = 0; i < numChildren; i++) {
for(变量i=0;i
谢谢,它成功了!我的意思是,当我运行代码时,文档文本似乎是正确的(从右到左)在Android浏览器上,但在PC浏览器上是从左到右!!!这两个平台,在相反的方向上显示相同的文本!换句话说,Android浏览器显示从右到左的右对齐文本,左对齐!!!有解决方案吗?不确定你想解释什么,你能拿一些截图来比较这两个并添加它们吗o您的帖子需要更多信息吗?当然!…谢谢。以下是截图:谢谢,尝试解决方案,看看它是否解决了您的问题。谢谢,它起作用了!我的意思是,当我运行代码时,文档文本似乎是对的(从右到左)在Android浏览器上,但在PC浏览器上是从左到右!!!这两个平台,在相反的方向上显示相同的文本!换句话说,Android浏览器显示从右到左的右对齐文本,左对齐!!!有解决方案吗?不确定你想解释什么,你能拿一些截图来比较这两个并添加它们吗o您的帖子需要更多信息吗?当然!谢谢。以下是截图:谢谢,尝试解决方案,看看它是否解决了您的问题。