java - 如何以编程方式在布局点击位置添加视图?
问题描述
如何在点击布局的地方创建视图?图片中是这样的:
该表是根据每天的相对布局构建的。
<ScrollView
android:id="@+id/calendarScrollView"
...... >
<RelativeLayout
android:id="@+id/calendarRelativeLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="0dp" >
<LinearLayout
android:id="@+id/calendarSplitterRelativeLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:padding="0dp" >
.......
<RelativeLayout
android:id="@+id/mondayRelativeLayout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2" >
<include layout="@layout/calendar_zebra" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/tuesdayRelativeLayout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2" >
<include layout="@layout/calendar_zebra" />
<com.example.admin.nuschedule.view.LessonEventView
android:layout_width="match_parent"
android:layout_height="60dp"
app:lessonName="CSCI 321"
app:lessonRoom="7.257"/>
</RelativeLayout>
.......
</LinearLayout>
</RelativeLayout>
</ScrollView>
实际上,我想我应该听一下 relativelayout 点击并以编程方式添加新视图
现在任何人都可以如何在代码中实现它吗?
解决方案
推荐阅读
- leaflet - 如何从传单中的地图中删除所有特征组?
- angular - 如何配置我的 Angular 库以依赖 Angular Material?
- javascript - 通过js文件到laravel的ajax调用
- asp.net - 尝试从视图访问模型到控制器编辑方法
- arrays - 根据另一个属性值在对象数组中查找属性值
- c - Flex 字符串识别“无法识别的规则”错误
- google-sheets - 如何将工作表查询结果折叠到单个单元格中
- spring-boot - Jhipster - 在 JHI_User 和另一个实体之间创建关系错误
- javascript - JS:检测被监视的 div 的 dom 突变(或将事件侦听器更改为 innerHTML)
- django - 如何将三个输入组合到一个变量中并使用它使用 Django 从数据库中获取数据?