源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Android layout_weight使用方法及实例

  • 时间:2020-10-15 09:53 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Android layout_weight使用方法及实例
直接上代码和图片。 情况一: [html]
[u]复制代码[/u] 代码如下:
<?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>
[img]http://files.jb51.net/file_images/article/201306/201363111107016.jpg[/img] 情况2: [html]
[u]复制代码[/u] 代码如下:
<?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>
[img]http://files.jb51.net/file_images/article/201306/201363111247732.jpg[/img] 情况三: Fragment这个东西在wrap_content的情况下会占据全部,和控件不太一样。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部