【问题标题】:How to add a landscape layout only for one of the fragments in an activity in Android?如何仅为 Android 活动中的一个片段添加横向布局?
【发布时间】:2012-01-20 15:15:40
【问题描述】:

我有一个包含许多片段的活动。我想将纵向和横向方向设置为仅片段之一,例如片段A。我不希望屏幕在横向模式下显示其他片段。

所以我将以下内容放入清单文件中:

   <activity
        android:name=".MyMainActivity" android:configChanges="orientation"
            android:screenOrientation="portrait" android:windowSoftInputMode="adjustPan|adjustResize">
    </activity>

但这阻止了片段A以横向模式显示。

我为 fragmentA 放置了 2 个不同的布局,即一个在 layout-land 和 layout 文件夹中。

【问题讨论】:

    标签: android layout android-activity fragment landscape-portrait


    【解决方案1】:

    如果您在 res 文件夹下使用 xml 进行布局。您可以在此处定义 android screenorientation="potrait"。我希望它能够在不影响其他片段的情况下正常工作

    【讨论】:

    • 它不工作,我不清楚你想说什么...你能说清楚一点吗?
    猜你喜欢
    • 1970-01-01
    • 2012-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-25
    • 1970-01-01
    相关资源
    最近更新 更多