分层 - 怎么样?

问题描述 投票:0回答:2

我需要我的图像在我的布局上有边缘底部,所以我尝试使用框架布局来制作我需要的东西,但我的图像不能离开framelayout边框。比我试图使用相对布局,我有同样的问题。我在stackoverflow上阅读了一些帖子,但我没有找到解决方案,所有帖子都是关于“如何在视图上制作图像”

我需要的:

enter image description here

这是我如何尝试:

<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:gravity="center_horizontal"
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:background="@color/colorPrimaryDark"
tools:context="com.partyticket.root.partytickets.LoginActivity">

<!-- Login progress -->
<ProgressBar
    android:id="@+id/login_progress"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:visibility="gone" />


<RelativeLayout
    android:id="@+id/containerLayout"
    android:layout_centerVertical="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:background="@color/colorPrimary"
    >
    <LinearLayout
        android:id="@+id/email_login_form"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">


            <EditText
                style="@style/App_EditTextStyle"
                android:id="@+id/email"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/prompt_email"
                android:layout_marginRight="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginBottom="7dp"
                android:inputType="textEmailAddress"
                android:maxLines="1"
                android:singleLine="true" />

            <EditText
                style="@style/App_EditTextStyle"
                android:id="@+id/password"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/prompt_password"
                android:imeActionId="6"
                android:layout_marginRight="10dp"
                android:layout_marginLeft="10dp"
                android:imeActionLabel="@string/action_sign_in_short"
                android:imeOptions="actionUnspecified"
                android:inputType="textPassword"
                android:maxLines="1"
                android:singleLine="true" />


        <Button
            android:id="@+id/email_sign_in_button"
            style="?android:textAppearanceSmall"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:text="@string/action_sign_in"
            android:textStyle="bold" />

    </LinearLayout>

</RelativeLayout>

<ImageView
    android:layout_width="81dp"
    android:layout_height="81dp"
    android:layout_above="@+id/containerLayout"
    android:layout_marginTop="42dp"
    android:src="@drawable/partytickets_small_logo" />
</RelativeLayout>
android android-layout
2个回答
1
投票

使用协调器布局而不是相对布局,而不是在ImageView的属性中使用以下内容

app:layout_anchor="@id/your Layout Wich Will Be under the Image"
app:layout_anchorGravity="center_horizontal"

希望这会有所帮助,这是我所知道的唯一方式。


0
投票

为什么不为图像使用高程属性。

© www.soinside.com 2019 - 2024. All rights reserved.