【问题标题】:Landscape layout in portrait orientation android纵向android中的横向布局
【发布时间】:2017-04-18 18:25:58
【问题描述】:

我想将横向 xml 显示为纵向模式。下面是示例:

我已尝试制作 layout-land 文件夹并将 xml 添加到纵向活动中并将其附加到纵向活动中,但这不起作用。

请帮助我一些想法或任何事情。

【问题讨论】:

    标签: android android-layout android-toolbar android-orientation


    【解决方案1】:

    您必须强制您的 Activity 在您的 Manifest.xml 文件中始终以横向模式显示:

     <activity
                android:name=".ui.loading.LoadingActivity"
                android:label="@string/app_name"
                android:noHistory="true"
                android:screenOrientation="landscape">
    

    【讨论】:

    • 对于这种表格视图,我应该使用 tablayout 还是 gridlayout?
    • 我认为您应该使用 TableLayout,因为在这种情况下,您将对单元格有更多的控制权。
    【解决方案2】:

    简单,只需添加

    android:rotation = "90"
    

    到你的 XML 布局 这将帮助您像横向一样纵向显示

    或 甚至你也可以从 Java 中做同样的事情:

    yourLayout  = (LinearLayout) findViewById(R.id.your_id);
    yourLayout.setRotation(90.0f);
    

    您至少需要 API 级别 11 才能使用轮换

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多