Respuestas:
this.getWindow().getDecorView().findViewById(android.R.id.content)
o
this.findViewById(android.R.id.content)
o
this.findViewById(android.R.id.content).getRootView()
setContentView(R.layout.my_view), esto devuelve el padre de ese diseño.
Puede recuperar la vista si coloca una ID en su diseño.
<RelativeLayout
android:id="@+id/my_relative_layout_id"
Y llámalo desde findViewById ...
findViewById?
Kotlin this.findViewById<View>(android.R.id.content)
.rootView
.setBackgroundColor(ContextCompat.getColor(this, R.color.black))
No existe el método "isContentViewSet". Puede poner alguna llamada simulada requestWindowFeature en el bloque try / catch antes de setContentView de esta manera:
tratar {
requestWindowFeature (Window.FEATURE_CONTEXT_MENU);
setContentView (...)
} catch (AndroidRuntimeException e) {
// hacer algo o nada
}
Si la vista de contenido ya estaba configurada, requestWindowFeature arrojará una excepción.
La mejor opción que encontré y la menos intrusiva, es establecer un parámetro de etiqueta en tu xml, como
DISEÑO XML DE TELÉFONO
<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"/>
DISEÑO XML DE TABLETA
<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>
y luego llame a esto en su clase de actividad:
View viewPager = findViewById(R.id.pager);
Log.d(getClass().getSimpleName(), String.valueOf(viewPager.getTag()));
Espero que funcione para ti.
getWindow().findViewById(android.R.id.content):)