【问题标题】:Android: screen orientation with FrameLayout & relativeLayout [duplicate]Android:带有FrameLayout和relativeLayout的屏幕方向[重复]
【发布时间】:2011-02-02 07:13:23
【问题描述】:

我有一个 android 应用程序,它由 FrameLayout 的主布局组成,在 RelativeLayout 中设置了两个视图。 (请参阅下面的布局 XML 文件)。 问题在于第二个视图 (view2) 的屏幕方向(视图变为黑色并且应用程序被冻结)。

我尝试使用该选项没有成功 机器人:方向=“水平” 在布局土地资源中。

请指教。

谢谢。 橡树人

main.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include android:id="@+id/notelist" layout="@layout/view1" />
<include android:id="@+id/notelist" layout="@layout/view2" />
</FrameLayout>

view1.xml

<RelativeLayout android:id="@+id/Layout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:id="@+id/image01"
android:layout_height="wrap_content"
>
</ImageView>
</RelativeLayout>

view2.xml

<RelativeLayout android:id="@+id/Layout02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:id="@+id/image02"
android:layout_height="wrap_content"
>
</ImageView>
</RelativeLayout>

【问题讨论】:

    标签: android orientation android-relativelayout android-framelayout


    【解决方案1】:

    Android 文档说

    框架布局 FrameLayout 是最简单的布局对象类型。它基本上是屏幕上的一个空白区域,稍后您可以用 单个 对象填充它——例如,您将换入和换出的图片。 FrameLayout 的所有子元素都固定在屏幕的左上角;您不能为子视图指定不同的位置。 随后的子视图将被简单地绘制在之前的子视图上,部分或完全遮盖它们(除非较新的对象是透明的)。

    你有两个孩子,一个比另一个。我假设这就是你想要的,对吗?您是否尝试将图像视图直接放入框架布局中?那有什么效果呢?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-08
      • 2014-02-08
      • 2013-05-25
      • 1970-01-01
      • 2017-11-28
      • 1970-01-01
      • 1970-01-01
      • 2011-09-09
      相关资源
      最近更新 更多