android - 如何隐藏根视图,直到它准备好输入?
问题描述
我正在添加这样的布局OnCreate
......
SetContentView(Resource.Layout.Main);
在它第一次出现和它准备好接收用户输入之间有一个难看的停顿。在此期间,它还覆盖了背景,它是一个加载场景。
因此,如何将布局及其控件设置为在完成构建之前不可见?
我试过这个...
var root = FindViewById<Layout>(Resource.Layout.Main);
root.Visibility = ViewStates.Invisible;
...但根是null
.
解决方案
布局有它的 Main
根视图,你可以控制这个视图来实现你的想法。在 XML 中:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"> //Initial status
.......
并使用 java 代码:
ConstraintLayout root = (ConstraintLayout)findViewById(R.id.root);
root.setVisibility(View.GONE);
推荐阅读
- html - 为什么 SVG 元素不能在 ios 设备上运行?
- sql - BigQuery 错误“查询未返回任何结果”
- ruby-on-rails - 更新单一资源模型时重定向到错误的 url
- cygwin - 更正“无法打开共享对象文件”错误,但 Cygwin 中报告的文件不正确?
- python - 在 Python 中使用 break 和 continue 语句的 while 循环?
- facebook - Facebook API 不返回评论、作者姓名和图片的字段“FROM”
- r - 在匹配多个条件时更改 R 数据框的 colname
- javascript - 我的页面不会自动刷新 - laravel
- ios - lineChartView 轴标签在标签上添加额外的线
- python - 如何使用 BeautifulSoup 抓取网站中的每个页面