How To Make Layout To Be 80% Of The Width Of The Screen?
How can I make some layout to be for example 80% or 90% of the width of the screen, no matter what is the screen size or DPI? I tried with ' but I get 80% of the height then. EDIT:
Solution 1:
android:layout_weight
is based on the android:orientation
of your LinearLayout
- if you want your layout to take up 80% of the width, you need a LinearLayout
with an android:orientation="horizontal"
<LinearLayout
android:id="@+id/your_outer_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" > <!-- note that vertical is the default -->
<!-- Other elements here -->
<LinearLayout
android:id="@+id/eighty_percent_layout_holder
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<View
android:id="@+id/your_eighty_percent_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8" />
</LinearLayout>
<!-- Other elements here -->
</LinearLayout>
Post a Comment for "How To Make Layout To Be 80% Of The Width Of The Screen?"