简体   繁体   中英

How can I add a footer-sized image to the bottom of any mobile application?

有没有办法将页脚大小的图像添加到任何移动应用程序的底部?

The best way to do this is by adding a layout set to the bottom of you activity while letting the rest of the screen scrollable. You can achive this by doing the following:

<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"
    tools:context=".MainActivity" >

    <ScrollView
        android:id="@+id/scrollablContent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/footerView"
        android:layout_below="@+id/headerView" >

        <LinearLayout
            android:id="@+id/content"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
        </LinearLayout>
    </ScrollView>

    <LinearLayout
        android:id="@+id/footerView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >
        <ImageView
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:src="@drawable/image_name" /> 
    </LinearLayout>

</RelativeLayout>

You can also remove the bottom LinearLayout if you just wish to add an Image and nothing in addition to it. Also similarly a header can be added.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM