gpt4 book ai didi

android - 如何在横向布局中包含纵向布局?

转载 作者:行者123 更新时间:2023-11-30 01:27:23 24 4
gpt4 key购买 nike

我设计了完美的纵向布局。我想将 is 作为横向版本的一部分包含在内(见附件)。

Layout for Landscape version

没有额外的功能,所以我认为没有必要费心使用 Fragments。

当然,不能在横向版本中包含布局的纵向版本。以下代码会产生“布局不应包含自身”的明显错误:

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>

<include
android:layout_width="wrap_content"
android:layout_height="match_parent"
layout="@layout/my_perfect_layout"
/>

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/demo"
/>
</LinearLayout>

有没有办法强制布局目录,这样我就不会得到这个 include 无限循环?还是完全有另一种方法?此时我真的很想避免更改任何 Java 代码!

最佳答案

最佳实践:

  • 将您的内容布局放入无方向布局文件中。 (这是可重复使用的部分)
  • 为您要使用的所有方向创建一个框架布局文件,并包括内容布局。 (这是放置特定于布局的部分的部分,例如在横向中包含更多内容)

关于android - 如何在横向布局中包含纵向布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36265749/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com