134.s1-ListView中下面添加layout_weight按钮渲染的方法

ListView布局权重详解
本文介绍如何利用android:layout_weight属性调整ListView中元素的渲染顺序及布局分配,通过具体XML示例展示如何实现不同组件间的优先级调整,使TextView能够自适应布局。

在LIstView中使用android:layout_weight="1111"可以修改页面的渲染顺序,必读下面的代码,下面代码中的三个组件中先渲染第一个ImageView再渲染第二个ImageView最后再渲染TextView,这样可以让TexTview自己做到适配

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

    <ImageView 
        android:id="@+id/iv_icon"
        android:layout_width="50dp"
    	android:layout_height="50dp"
    	android:src="@drawable/ic_launcher"
        />
    <TextView 
        android:id="@+id/tv_name"
        android:layout_width="match_parent"
    	android:layout_height="wrap_content"
    	android:text="应用的名字"
    	android:layout_weight="1111"
        />
    <ImageView 
        android:id="@+id/iv_icon"
        android:layout_width="50dp"
    	android:layout_height="50dp"
    	android:src="@drawable/list_button_lock_default"
        />
</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="vertical" >
    

    <TextView 
        style="@style/TitleStyle"
        android:text="进程管理"
        />
    <LinearLayout 
        android:layout_width="match_parent"
    	android:layout_height="wrap_content"
    	android:orientation="horizontal"
        >
        <TextView 
            android:id="@+id/tv_task_process_count"
            android:layout_width="wrap_content"
    		android:layout_height="wrap_content"
    		android:text="进行中进程1个"
    		android:layout_weight="1"
    		android:layout_marginLeft="5dp"
    		android:textColor="@color/black"
            />
		<TextView 
		    android:id="@+id/tv_task_memory"
            android:layout_width="wrap_content"
    		android:layout_height="wrap_content"
    		android:text="剩余/总内存"
    		android:layout_weight="1"
    		android:layout_marginLeft="5dp"
    		android:textColor="@color/black"
            />        
    </LinearLayout>
    <ListView 
        android:id="@+id/list_view"
        android:layout_width="match_parent"
    	android:layout_height="match_parent"
    	android:layout_weight="1111"
        ></ListView>
    <LinearLayout 
        android:layout_width="match_parent"
    	android:layout_height="wrap_content"
    	android:orientation="horizontal"
        >
        <Button 
            android:layout_width="wrap_content"
    		android:layout_height="wrap_content"
    		android:layout_weight="1"
    		android:text="全选"
            />
        <Button 
            android:layout_width="wrap_content"
    		android:layout_height="wrap_content"
    		android:layout_weight="1"
    		android:text="反选"
            />
        <Button 
            android:layout_width="wrap_content"
    		android:layout_height="wrap_content"
    		android:layout_weight="1"
    		android:text="清理"
            />
        <Button 
            android:layout_width="wrap_content"
    		android:layout_height="wrap_content"
    		android:layout_weight="1"
    		android:text="设置"
            />
        
    </LinearLayout>
</LinearLayout>

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值