Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Activity's content view?

Tags:

android

People also ask

How can I get current view of activity?

android. R. id. content will give the entire view of the present activity.

What is content view in Android?

Actually setContentView() is a method part of android. app. Activity class. It helps to set our content or render our layout on the screen. Based on the value given by the user, views will be inflated and rendered after the measurement of the screen, root view, and its child views.


this.getWindow().getDecorView().findViewById(android.R.id.content)

or

this.findViewById(android.R.id.content)

or

this.findViewById(android.R.id.content).getRootView()

You can get the view Back if you put an ID to your Layout.

<RelativeLayout
    android:id="@+id/my_relative_layout_id"

And call it from findViewById ...


How about

View view = Activity.getCurrentFocus();

You may want to try View.getRootView().


You can also override onContentChanged() which is among others fired when setContentView() has been called.