Android layout_weight使用方法及實(shí)例
直接上代碼和圖片。
情況一:
[html]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<fragment
android:id="@+id/titles"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
class="com.a2bgeek.fragmentdemo.TitlesFragment" />
<FrameLayout
android:id="@+id/details"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="2" >
</FrameLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<fragment
android:id="@+id/titles"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
class="com.a2bgeek.fragmentdemo.TitlesFragment" />
<FrameLayout
android:id="@+id/details"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="2" >
</FrameLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<fragment
android:id="@+id/titles"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
class="com.a2bgeek.fragmentdemo.TitlesFragment" />
<FrameLayout
android:id="@+id/details"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="2" >
</FrameLayout>
</LinearLayout>
情況2:
[html]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<fragment
android:id="@+id/titles"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
class="com.a2bgeek.fragmentdemo.TitlesFragment" />
<FrameLayout
android:id="@+id/details"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2" >
</FrameLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<fragment
android:id="@+id/titles"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
class="com.a2bgeek.fragmentdemo.TitlesFragment" />
<FrameLayout
android:id="@+id/details"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2" >
</FrameLayout>
</LinearLayout>
情況三:
Fragment這個(gè)東西在wrap_content的情況下會(huì)占據(jù)全部,和控件不太一樣。
相關(guān)文章
AndroidStudio3 支持 Java8 了請(qǐng)問(wèn)你敢用嗎
Google 發(fā)布了 AS 3.0,以及一系列的 Support 包,有意思的新東西挺多,AS3里面有一個(gè)亮眼的特性就是支持J8。接下來(lái)通過(guò)本文給大家分享AndroidStudio3 支持 Java8 的相關(guān)內(nèi)容,感興趣的朋友一起看看吧2017-11-11android使用NotificationListenerService監(jiān)聽(tīng)通知欄消息
本篇文章主要介紹了android使用NotificationListenerService監(jiān)聽(tīng)通知欄消息,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。2017-01-01Android動(dòng)態(tài)更新Menu菜單的實(shí)現(xiàn)過(guò)程
菜單是用戶(hù)界面中最常見(jiàn)的元素之一,使用非常頻繁,下面這篇文章主要給大家介紹了關(guān)于Android動(dòng)態(tài)更新Menu菜單的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-09-09Android中使用socket使底層和framework通信的實(shí)現(xiàn)方法
native和framework的通信是通過(guò)jni,但是這一般只是framework調(diào)用native,native如果有消息要怎樣通知上層 呢?android中GSP模塊提供一種解決思路,但是實(shí)現(xiàn)有些復(fù)雜,這里介紹一種使用socket通信的方法可以使native和framework自由通信,感興趣的朋友一起看看吧2016-11-11Rxjava實(shí)現(xiàn)發(fā)送驗(yàn)證碼倒計(jì)時(shí)功能
這篇文章主要為大家詳細(xì)介紹了Rxjava實(shí)現(xiàn)發(fā)送驗(yàn)證碼倒計(jì)時(shí)功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-06-06解決Android橫豎屏切換數(shù)據(jù)丟失問(wèn)題的方法
這篇文章主要為大家詳細(xì)介紹了Android橫豎屏切換數(shù)據(jù)丟失問(wèn)題的解決方法,感興趣的小伙伴們可以參考一下2016-05-05Android利用控制點(diǎn)的拖拽畫(huà)一個(gè)粽子
端午節(jié)就要到了,本文我們將利用控制點(diǎn)的拖拽式移動(dòng),動(dòng)態(tài)調(diào)整位置來(lái)調(diào)整繪制一個(gè)簡(jiǎn)單的粽子圖形,感興趣的小伙伴可以跟隨小編一起動(dòng)手嘗試一下2022-05-05