android中如何讓一個不知道高度的控件正好恰在上下兩個控件之中
原創(chuàng) Aiven 最后發(fā)布于2012-03-26 08:08:07 閱讀數(shù) 2017 收藏
https://blog.csdn.net/aiven163/article/details/7393486
展開
android中如何讓一個不知道高度的控件正好恰在上下兩個控件之中:
? 解決辦法:比如一個ListView,外面是一個LinearLayout控制,
? <ListView
? ? ? android:id="@+id/searchstock_listview"
? ? ? android:layout_width="fill_parent"
? ? ? android:layout_height="fill_parent"?
? ? ? android:layout_marginBottom="1dip"
? />
如果LinearLayout中包含三個控件,而中間一個是ListView,那么只是按照上面這樣寫一個ListView是不行的,它將會把下面的一個組件給覆蓋掉。而我們又不知道應(yīng)該設(shè)置多少個像素的高度,那么解決的辦法就是在這個組件中加一個屬性:android:layout_weight="1.0",這樣他就會剛好卡在上下兩個組件之間,前提是高度應(yīng)該設(shè)為fill_parent。
? <ListView
? ? ? ? android:id="@+id/searchstock_listview"
? ? ? ? android:layout_width="fill_parent"
? ? ? ? android:layout_height="fill_parent"
? ? ? ? android:layout_weight="1.0"
? ? ? ? android:layout_marginBottom="1dip"
? />
————————————————
版權(quán)聲明:本文為CSDN博主「Aiven」的原創(chuàng)文章,遵循 CC 4.0 BY-SA 版權(quán)協(xié)議,轉(zhuǎn)載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/aiven163/article/details/7393486