java 如何控制安卓控件_Android动态添加设置布局与控件的方法

本文实例讲述了Android动态添加设置布局与控件的方法。分享给大家供大家参考,具体如下:有时候我们会在代码端,动态的设置,添加布局和控件。下面我们就看来看一下如何处理,直接上代码,代码里面的注解很清楚了。布局文件:fragment_hot.xml说明:这个部局,我用的是scrollView做为基础布局,主要是为了实现一个滚动。这里不多说,这个你可以使用任何布局都可以,这里的id我是提前定义的。这...
摘要由CSDN通过智能技术生成

本文实例讲述了Android动态添加设置布局与控件的方法。分享给大家供大家参考,具体如下:

有时候我们会在代码端,动态的设置,添加布局和控件。下面我们就看来看一下如何处理,直接上代码,代码里面的注解很清楚了。

布局文件:fragment_hot.xml

说明:这个部局,我用的是scrollView做为基础布局,主要是为了实现一个滚动。这里不多说,这个你可以使用任何布局都可以,这里的id我是提前定义的。

这里面的现在有的布局是我为了看到我在代码端,动态添加的代码,是否可以追加到现有布局的后面而加上,这里大家可以自己设置

android:id="@id/id_stickynavlayout_innerscrollview"

android:layout_width="match_parent"

android:layout_height="match_parent">

android:id="@+id/line_fragment_hot_main"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical">

android:layout_width="fill_parent"

android:layout_height="80dp"

android:orientation="horizontal">

android:layout_width="0dp"

android:layout_height="70dp"

android:layout_weight="1">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:src="@drawable/desktop_device"/>

android:layout_width="0dp"

android:layout_height="70dp"

android:layout_weight="1"

android:orientation="vertical">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="燕郊孔雀城"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="燕郊 燕郊"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="3万抵6万"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="6000元/m"/>

android:layout_width="0dp"

android:layout_height="70dp"

android:layout_weight="1"

android:gravity="right">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="剩2天"

android:textColor="#F97F49"

android:textSize="12dp"

android:textStyle="bold"

android:layout_marginTop="2dp"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background&

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值