How to programatically determine which XML layout my Android apps is using?
android, android-layout
Solution
An extremely easy way to do this, is by setting a id and tag to the parent layout and in your `onCreate()`, you can `findViewById()` and `getTag()`.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/my_activity_view"
android:tag="big_screen" >
// misc views~
</RelativeLayout>
And then, in your `onCreate` method,
if(findViewById(R.id.my_activity_view).getTag().equals("big_screen")) {
// do stuff
}
Problem
How do I programatically determine which layout (layout-normal, layout-large, etc.) my app is currently using? I see the getWindowManager().getDefaultDisplay().getMetrics(metrics) call but it seems to only deal with screen density but not necessary which layout the app is using. I need the info since I need to programatically change some of the positioning of views dynamically at runtime. Thanks in advance.