日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

android在屏幕最下方,如何将view固定在屏幕底部?

發布時間:2024/10/8 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android在屏幕最下方,如何将view固定在屏幕底部? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

答:Janusz

(最佳答案)

我認為你可以試試RelativeLayout.,這樣你可以用android:layout_alignParentBottom將button移動到屏幕底部。如果在Relative Layout中,底部沒有顯示相關內容,或許就是在它之前的layout占據了整個屏幕。如果出現這種情況,你可以最先在layout文件夾中設定view的位置,然后用android:layout_above將其它的內容設置在view之上。這樣,底部的view可以占據更多的空間,layout中其它的內容也可以充分顯示。

答:Bram Avontuur

在ScrollView中,這種方法不起作用,因為無論ScrollView是否置于底部,RelativeLayout都會重疊。所以,我選擇FrameLayout來進行固定:

android:layout_height="fill_parent" android:layout_width="fill_parent"

android:fillViewport="true">

android:layout_width="fill_parent" android:layout_height="fill_parent"

xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical">

android:layout_width="fill_parent" android:layout_height="fill_parent"

android:layout_weight="1">

答:pseudosudo

你可以在Linear Layout中新建RelativeLayout:

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent">

android:id="@+id/TextView"

android:layout_width="fill_parent"

android:layout_height="wrap_content">

android:layout_width="match_parent"

android:layout_height="match_parent">

android:id="@+id/Button"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentBottom="true"

android:layout_alignParentRight="true">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_toLeftOf="@id/Button"

android:layout_alignParentBottom="true">

答:Timores

Janusz的答案很正確,但是我覺得用RelativeLayouts并不是最佳選擇,所以我介紹一種“filler”方法,將TextView設定為空白:

android:layout_width="fill_parent"

android:layout_weight="1" />

總結

以上是生活随笔為你收集整理的android在屏幕最下方,如何将view固定在屏幕底部?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。