【问题标题】:Is possible split an image in two different layouts?是否可以将图像拆分为两种不同的布局?
【发布时间】:2017-05-09 06:12:36
【问题描述】:

有可能吗?我使用一些屏幕来帮助您理解。

这是我的应用,没有 2 个布局:

结束 这是第二个布局(我需要第二个布局,但 我想看图片丢失的部分):

这是我的 xml 代码:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?attr/actionBarSize"
tools:context=".Utenti.Profilo.ProfiloFragment">

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:background="@drawable/side_nav_bar"
    android:gravity="bottom"
    android:id="@+id/linearLayout2"
    android:orientation="vertical"
    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:theme="@style/ThemeOverlay.AppCompat.Dark"
    android:weightSum="1"
    android:layout_height="110dp">

</LinearLayout>

<ImageView
    android:id="@+id/imgProfilo"
    android:layout_width="75dp"
    android:layout_height="wrap_content"
    android:paddingTop="@dimen/nav_header_vertical_spacing"
    android:src="@android:drawable/sym_def_app_icon"
    android:adjustViewBounds="false"
    android:baselineAlignBottom="false"
    android:layout_gravity="center"
    android:layout_centerHorizontal="true" />

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="@dimen/nav_header_vertical_spacing"
    android:text="AndroHouse"
    android:layout_gravity="center"
    android:textAppearance="@style/TextAppearance.AppCompat.Body1"
    android:id="@+id/nome_utente"
    android:textAlignment="center"
    android:layout_alignParentTop="true"
    android:layout_alignParentEnd="true"
    android:textSize="18sp"
    android:textStyle="normal|bold" />

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/linearLayout2">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">


        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

        <ImageView
            android:id="@+id/myImageView"
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:scaleType="centerCrop" />

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabMode="fixed"
            app:tabGravity="fill"/>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_height="match_parent" />
</android.support.design.widget.CoordinatorLayout>

【问题讨论】:

  • 我在您分享的 xml 代码中没有看到协调器布局
  • 是的,有.. schemas.android.com/apk/res/android" xmlns:app="schemas.android.com/apk/res-auto" android:layout_width="match_parent" android: layout_height="match_parent" android:layout_below="@+id/linearLayout2">
  • 一定错过了抱歉。好的,在 RelativeLayout 中,项目的 z 值(高度)与您将它们添加到视图中的顺序直接相关。因此,只需尝试交换协调器布局和线性布局的位置(在布局文件中)。
  • 那么成功了吗? @francesco
  • 是的,工作。对不起,我不能给你分数,因为我超过 15 分

标签: android xml image layout


【解决方案1】:

在 RelativeLayout 中,项目的 z 值(高度)与您将它们添加到视图中的顺序直接相关。并且项目从 xml 文件中以自上而下的顺序添加到视图中

所以只需尝试交换协调器布局和线性布局的位置(在布局文件中)。

【讨论】:

    猜你喜欢
    • 2014-09-16
    • 2011-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-19
    • 1970-01-01
    • 2019-07-17
    相关资源
    最近更新 更多