Reputation: 6143
Right now I have views with layout_weight inside another view that also has the same attribute, which causes the outer view to be calculated exponentially. I'm considering nesting another set of views with weights inside of the inner view, but that would cause the outermost view to be calculated more times than I would like. I'm just splitting the areas up evenly (each view within a group all have the same weight), but I want everything to scale properly regardless of what size or DPI the screen is. Is there any other way to efficiently split views within another view?
Upvotes: 1
Views: 401
Reputation: 6143
DeeV's answer to this question does a good job of it:
Swap your top
LinearLayout
with aRelativeLayout
and align the two children to an >invisibleView
in the center like so:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/top"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/center_point"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerInParent="true"/>
<LinearLayout
android:id="@+id/left_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignRight="@+id/center_point>
</Linearlayout>
<LinearLayout
android:id="@+id/right_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignLeft="@+id/center_point>
</Linearlayout>
</RelativeLayout>
Upvotes: 2