11

我有希伯来语的 TextView 我想在右边,所以我在做

<TextView....
    android:gravity="right"
</TextView>

在某些手机上,它会向右对齐,而在某些手机上,它会向左对齐。我认为这取决于某些手机配置。我该如何解决?

谢谢。

4

7 回答 7

3

这可能是个问题。如果它不在 Android 的问题页面中,请考虑报告它。

现在,您可以尝试将其放置TextViewViewGroup. 使用wrap_contentandlayout_gravity将其正确放置在其父级中。

于 2011-06-27T13:20:31.757 回答
1

Android 目前不支持双向文本。一些制造商已经入侵了它,但在这成为平台的标准部分之前,您可以预期任何使用 BiDi 文本都会导致不一致、损坏的行为。对不起。

于 2011-07-01T00:52:07.923 回答
1

Android: Gravity可能无法正常工作以防万一android:layout_heightandroid:layout_weight设置为wrap_content.

于 2011-12-11T17:16:19.197 回答
0

我找到了解决方案。如果您的文本是希伯来语,则不需要设置重力,因为没有它就会对齐。当我在我的视图中看到拉丁符号时,我想到了这一点,它们在右边。不过,SDK 布局编辑器中仍然存在错误。

在 LG GT540 和三星 Galaxy S 上测试

于 2011-07-02T13:24:58.523 回答
0

如果您希望文本向右对齐,请尝试使用:

textView.setText("\u200F"+content);
于 2012-08-16T23:41:43.180 回答
0

发生这种情况是因为较旧的 android 版本不太支持 rtl。对我来说,最终起作用的是 webview。因为那时我只是使用 CSS 来设计我的文本。如果您希望它在单击时执行某些操作,您还需要一个 onTouchListener

将您的 TextView 更改为 Webview:

<WebView
        android:id="@+id/noticetit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

我的代码:

WebView webView = (WebView) findViewById(R.id.noticetit);
private void setWebView() {
            String htmlcss = "<html lang=\"he\"><head><meta charset=\"utf-8\" />"
                    + "<style type=\"text/css\">.rtl {direction: rtl;color:black;font:20px arial;}</style></head>"
                    + "<body class=\"rtl\"><div class=\"rtl\">" + webView
                    + "</div></body></html>";

            webView.loadDataWithBaseURL(null, htmlcss, "text/html", "utf-8", null);
            webView.setOnTouchListener(new OnTouchListener() {
                // Removed @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (v.getId() == R.id.maintitle
                            && event.getAction() == MotionEvent.ACTION_DOWN) {
                        //Put your code here
                    }
                    return false;
                }
            });
        }

希望这可以帮助你!

于 2014-03-27T19:53:08.150 回答
-1

我想这就是你要找的:

android:layout_gravity="right"
于 2011-04-05T19:51:45.977 回答