展会信息港展会大全

Android layout_weight用法图解
来源:互联网   发布日期:2015-10-13 15:22:39   浏览:2443次  

导读:直接上代码和图片。情况一:[html] <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="htt...

直接上代码和图片。

情况一:

[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>

html" name="code" style="display: none">

<?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>

<?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这个东西在wrap_content的情况下会占据全部,和控件不太一样。

赞助本站

人工智能实验室

相关热词: android开发 教程

AiLab云推荐
推荐内容
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港