Android Studio:布局层次问题

乔治·布鲁克斯

我有一个包含 1 个用作背景的图像的水平滚动视图。此图像可以从左向右滚动。我想将其他图像视图放在背景图像上,但不要让它们随它滚动。目前,如果我在此之上放置另一个图像视图,当我滚动图像时也会出现。

最左边的滚动视图:

在此处输入图片说明

最右侧的滚动视图:

在此处输入图片说明

XML 代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"   xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_rear_gunner"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:focusable="true"
tools:context="com.example.mr_br.ibcc_bomber_command.rear_gunner">


<HorizontalScrollView
    android:id="@+id/horizontalScrollView1"

    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true"
    android:layout_alignParentTop="true"
>


<ImageView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" app:srcCompat="@drawable/background_scroll_2"
    android:id="@+id/scrollView" android:layout_centerVertical="true"
    android:scaleType="centerCrop"

/>

</HorizontalScrollView>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/item_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:focusable="true"
    tools:context="com.example.mr_br.ibcc_bomber_command.rear_gunner">

</RelativeLayout>
<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" app:srcCompat="@drawable/placeholder_bomber"
    android:id="@+id/enemy" android:layout_centerVertical="true"


/>


</RelativeLayout>

在 android 中使用布局非常新。希望我说清楚我的问题,如果不是我道歉,如果被问到,我会尽力澄清。我知道这可能与我使用的布局以及他们的孩子和父母的布局有关,但就像我说的那样。

路易吉·帕皮诺

Horizo​​ntalSCrollView 只能有一个子级,但该子级可以是另一种布局,因此您可以添加任意数量的 ImageView。

  <HorizontalScrollView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      >
    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        >
      <ImageView
          android:layout_width="3000dp"
          android:layout_height="match_parent"
          android:background="#a30"
          />
      <ImageView
          android:layout_width="30dp"
          android:layout_height="30dp"
          android:background="#aa0"
          />
    </RelativeLayout>
  </HorizontalScrollView>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

布局渲染问题android studio 0.8.0

来自分类Dev

Android Studio 1.2.1.1布局预览问题

来自分类Dev

Android Studio 布局预览中的渲染问题

来自分类Dev

布局深度...?如何调整布局层次结构和图层?(Android Studio)

来自分类Dev

Android Studio(Android Studio 1.2)中的布局预览渲染问题

来自分类Dev

Android Studio是否具有层次结构查看器或布局检查器?

来自分类Dev

渲染问题:Android Studio 2.2-约束布局

来自分类Dev

Android Studio 3 约束布局编辑器问题

来自分类Dev

减少Android布局中的视图层次

来自分类Dev

Android布局问题

来自分类Dev

Android布局对齐问题

来自分类Dev

XML Android布局问题

来自分类Dev

Android缩放(布局)问题

来自分类Dev

Android:LinearLayout的布局问题

来自分类Dev

Android Textview布局问题

来自分类Dev

Android:设计布局问题

来自分类Dev

Android相对布局问题

来自分类Dev

XML Android布局问题

来自分类Dev

Android布局问题

来自分类Dev

android按钮布局问题

来自分类Dev

Xamarin Android布局问题

来自分类Dev

Android Studio工具布局

来自分类Dev

Android Studio布局错误

来自分类Dev

Android Studio布局预览

来自分类Dev

Android相对布局填充问题

来自分类Dev

android相对布局问题与按钮

来自分类Dev

Android Scrollview和布局问题

来自分类Dev

Android 相对布局设计问题

来自分类Dev

减少Android布局中的视图层次结构