【问题标题】:Android - setLayoutDirection in API 15 and API 16Android - API 15 和 API 16 中的 setLayoutDirection
【发布时间】:2017-05-08 07:35:14
【问题描述】:

有人知道ViewCompat.setLayoutDirection 是否在 API 级别 17 下工作?

我在整个互联网上搜索解决方案,但找不到可靠的解决方案。

【问题讨论】:

标签: android android-layout right-to-left android-api-levels


【解决方案1】:

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" 对吧?在这种情况下可能会有所帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-10
    • 2016-12-17
    • 2012-11-12
    • 1970-01-01
    • 1970-01-01
    • 2017-03-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多