如何在页面底部放置图像

时间:2015-08-26 06:33:05

标签: android xml

我试图将图片放在页面底部。我试图通过使用android:gravity =" bottom"但是,我的图像没有与页面底部对齐。

这是我的XML,

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:id="@+id/LinearLayout1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <ProgressBar
            android:id="@+id/progressBar1"
            style="?android:attr/progressBarStyleLarge"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/login_land_layout_margin"
            android:orientation="vertical" >

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:contentDescription="@string/logo"
                android:src="@drawable/ic_logo" />

            <EditText
                android:id="@+id/codeEdit"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:ems="10"
                android:hint="@string/code"
                android:textColorHint="#FFFFFF"
                android:inputType="textPassword" >

                <requestFocus />
            </EditText>

            <EditText
                android:id="@+id/nameEdit"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:ems="10"
                android:hint="@string/name"
                android:textColorHint="#FFFFFF"
                android:inputType="textPersonName" />

            <EditText
                android:id="@+id/emailEdit"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:ems="10"
                android:hint="@string/email"
                android:textColorHint="#FFFFFF"
                android:inputType="textEmailAddress" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/login_land_margin_both"
                android:layout_marginRight="@dimen/login_land_margin_both"
                android:orientation="vertical" >

                <Button
                    android:id="@+id/loginBtn"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginTop="@dimen/login_Land_margin_top"
                    android:background="#0f4b9b"
                    android:text="@string/login"
                    android:textColor="@color/LoginButtonColor" />

            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >

        <ImageView
            android:id="@+id/poweredBy"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/poweredby"
            android:gravity="bottom"
            android:scaleType="fitXY"

            />
    </LinearLayout>


</RelativeLayout>

这是我的形象的视图。

image

我需要在页面底部添加powered by image。

2 个答案:

答案 0 :(得分:0)

无需使用该线性布局删除

<ImageView
            android:id="@+id/poweredBy"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/poweredby"
            android:layout_alignParentBottom="true"
            android:scaleType="center"

            />

在滚动浏览中添加此android:fillViewport="true"

答案 1 :(得分:-1)

您已将imageview小部件放置在Linearlayout中。请删除Linearlayout并仅使用ImageView小部件。使用以下代码将imageview放置在屏幕底部。

<ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/poweredby"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:scaleType="fitXY" />