タイトル通り、Android アプリで画像をページの下部に固定表示する方法についてです。
CSS で言うところの、position: fixed ですね。
Android でもできるのか調べてみましたが、どうやらやり方があるみたいです。
参考にさせていただいた記事はこちらから。
java – How to fix an ImageView to the bottom of a Layout? – Stack Overflow
https://stackoverflow.com/questions/8003130/how-to-fix-an-imageview-to-the-bottom-of-a-layout
サンプルコードは下記のとおりです。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
......
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="100dp"
android:src="@drawable/image"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
ポイントは、<ImageView> の 6行目の android:layout_alignParentBottom="true" です。
こちらを追加すると、画面の下部に <ImageView> が固定表示されるようになります。
なお、もし <ScrollView> を追加する場合には、この固定表示している <ImageView> は <ScrollView> の外側に置くようにしてください。
コードは以上です!
思っていた以上に簡単に実装できました!
以上、Android アプリで、ImageView を画面の下部に固定表示する方法についてでした。
ご参考になれば幸いです。