如何隐藏根视图,直到准备好输入?

时间:2018-08-19 21:53:04

标签: android xamarin

我正在OnCreate中添加这样的布局...

SetContentView(Resource.Layout.Main);

在它第一次出现与准备好接收用户输入之间有一个难看的停顿。在此期间,它还覆盖了背景,这是一个加载场景。

因此,如何设置布局及其控件在完成构建之前不可见?

我已经尝试过了...

var root = FindViewById<Layout>(Resource.Layout.Main);

root.Visibility = ViewStates.Invisible;

...但是根是null

1 个答案:

答案 0 :(得分:0)

gth布局具有其根视图,您可以控制该视图以实现您的想法。 在XML中:

Main

并使用jave代码:

  <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 

   .......