What is the default TextView Gravity?

It seems the text direction of the TextView (or Gravity) is automatically changed on Android when it receives text from RTL resources such as Arabic text or LTR resources such as English. What is the default direction of the TextView (or Gravity) and how to get it? Actually I'm trying to figure out which text language (RTL or LTR) is introduced? But what if it's hybrid text with RTL and LTR?

+4
source share
3 answers

What is the default direction of the TextView (or Gravity)

In the source code of a TextView, it is initialized as:

private int mGravity = Gravity.TOP | Gravity.START;

, Gravity.TOP Gravity.START. START LTR RTL.

, ( Gravity.START) - , (RTL LTR) .

, RTL LTR; : Identifyng RTL- Android.

+3

TextView , ,

TextView textView = (TextView) findViewById(R.id.text_view);
int gravity = textView.getGravity();

8388659. 0x800033.

TextView . , TextView.

: 0x800033. 0x800003 | 0x30. , | .

+3

The default value of TextView is Gravity.TOP | Gravity.START

+1
source

Source: https://habr.com/ru/post/1614939/


All Articles