【发布时间】:2017-05-08 07:35:14
【问题描述】:
有人知道ViewCompat.setLayoutDirection 是否在 API 级别 17 下工作?
我在整个互联网上搜索解决方案,但找不到可靠的解决方案。
【问题讨论】:
标签: android android-layout right-to-left android-api-levels
有人知道ViewCompat.setLayoutDirection 是否在 API 级别 17 下工作?
我在整个互联网上搜索解决方案,但找不到可靠的解决方案。
【问题讨论】:
标签: android android-layout right-to-left android-api-levels
setLayoutDirection 已添加到 API 级别 17(阅读 here)中,即 4.2,因此旧版本不支持。因此,为更高和更低保留两个布局,您需要为低于 api 级别的 XML 视图工作。
如果您使用的是support 库,您可以执行以下操作:
if (ViewCompat.getLayoutDirection(view) == ViewCompat.LAYOUT_DIRECTION_RTL) {
// view -RTL layout
} else {
//view - set made layout for below apis
}
BidiFormatter 可能会根据您的要求为您提供帮助。请检查一下。
每个人都知道android:layout_gravity="end" 对吧?在这种情况下可能会有所帮助
【讨论】: