Respostas:
this.getWindow().getDecorView().findViewById(android.R.id.content)
ou
this.findViewById(android.R.id.content)
ou
this.findViewById(android.R.id.content).getRootView()
setContentView(R.layout.my_view), isso retornará o pai desse layout.
Você pode obter a visualização Voltar se colocar um ID no seu Layout.
<RelativeLayout
android:id="@+id/my_relative_layout_id"
E chame-o de findViewById ...
findViewById?
Kotlin this.findViewById<View>(android.R.id.content)
.rootView
.setBackgroundColor(ContextCompat.getColor(this, R.color.black))
Não existe um método "isContentViewSet". Você pode colocar alguma chamada fictícia requestWindowFeature no bloco try / catch antes de setContentView assim:
experimentar {
requestWindowFeature (Window.FEATURE_CONTEXT_MENU);
setContentView (...)
} captura (AndroidRuntimeException e) {
// faça smth ou nada
}
Se a visualização de conteúdo já estiver definida, requestWindowFeature lançará uma exceção.
A melhor opção que achei e menos invasiva é definir um parâmetro de tag no seu xml, como
LAYOUT DE TELEFONE XML
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="phone"/>
LAYOUT DE TABLET XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="tablet">
...
</RelativeLayout>
e chame isso em sua classe de atividade:
View viewPager = findViewById(R.id.pager);
Log.d(getClass().getSimpleName(), String.valueOf(viewPager.getTag()));
Espero que funcione para você.
getWindow().findViewById(android.R.id.content):)