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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

【转】 Android ListView与Button的显示----不错不错

發(fā)布時間:2025/4/16 49 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【转】 Android ListView与Button的显示----不错不错 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

原文網(wǎng)址:http://blog.csdn.net/zy987654zy/article/details/39225819

在開發(fā)中有時候會碰見一些很簡單的問題,但是當初沒想通的時候 死都搞不定。

?

我就碰見了一個簡單Layout的顯示問題。

界面中有一個ListView 然后ListView 下面跟著一個按鈕。

要求:ListView 數(shù)據(jù)充滿屏幕的時候 按鈕在屏幕底部, 不能從界面上消失。

ListView數(shù)據(jù)不夠充滿屏幕的時候,按鈕在ListView下面。而不是在屏幕底部。

也就是說 按鈕是能隨著ListView數(shù)據(jù)的增加而不斷的改變位置。但是不能從屏幕中移出去。

?

效果就是上面的圖

?

?

要做到上面的效果 只需要 設(shè)置layout 就可以了:

?

[java]?view plaincopy
  • <LinearLayout??
  • ?????android:layout_width="match_parent"??
  • ?????android:layout_height="wrap_content"??
  • ?????android:orientation="vertical"?>??
  • ??
  • ?????<ListView??
  • ?????????android:id="@+id/lv"??
  • ?????????android:layout_width="match_parent"??
  • ?????????android:layout_height="wrap_content"??
  • ?????????android:layout_weight="1"??
  • ?????????android:divider="@null"?/>??
  • ??
  • ?????<Button??
  • ?????????android:id="@+id/btn"??
  • ?????????android:layout_width="match_parent"??
  • ?????????android:layout_height="50dp"??
  • ?????????android:layout_margin="10dp"??
  • ?????????android:background="@drawable/btn"??
  • ?????????android:text="按鈕"??
  • ?????????android:textColor="#FFFFFF"??
  • ?????????android:textSize=10sp"?/>??
  • ?</LinearLayout>??

  • 其實關(guān)鍵地方只有兩個:

    ?

    1: ListView 的layout_weight="1";

    2:最外面的LinearLayout的高度必須設(shè)置成 wrap_content :?

    就能實現(xiàn)效果了。

    ?

    這篇主要是幫我記憶。

    轉(zhuǎn)載于:https://www.cnblogs.com/wi100sh/p/4488120.html

    總結(jié)

    以上是生活随笔為你收集整理的【转】 Android ListView与Button的显示----不错不错的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。