【发布时间】:2019-03-08 01:14:30
【问题描述】:
考虑以下 sn-ps:
<TextView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:text="StrangerThings"/>
Java端,
TextView tv =findViewById(R.id.tv);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) tv.getLayoutParams();
params.setMarginStart(0);
在 Android Manifest 中将 supportRTL 标志设置为 true,上述代码会按预期生成具有 0 边距的文本。但是,supportsRTL 为 false 时,setMarginStart 无效。
此外,如果 SupportsRTL 为 false,则无论您如何设置左边距(在 xml 中或以编程方式使用 setMargins),一旦设置了左边距,setMarginStart 对其没有任何影响。
这是预期的 android 行为还是错误?有人可以解释这种行为吗?
【问题讨论】:
标签: android layout right-to-left