Android layout_weight使用方法及实例
直接上代码和图片。
情况一:
[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这个东西在wrap_content的情况下会占据全部,和控件不太一样。
相关文章
实例讲解Android中的View类以及自定义View控件的方法
这篇文章主要介绍了Android中的View类以及自定义View控件的方法,讲解了如何继承View类并且展示了一个对View进行重绘的例子,需要的朋友可以参考下2016-04-04Android Material组件库日期选择和时间选择器的使用方法
这篇文章主要介绍了Android Material组件库(日期选择和时间选择器)基本使用,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧2023-11-11Android MVP BaseFragment 通用式封装的实现
这篇文章主要介绍了Android MVP BaseFragment 通用式封装的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2019-08-08
最新评论