java - How to make layout to be 80% of the width of the screen? -


how can make layout example 80% or 90% of width of screen, no matter screen size or dpi? tried " 80% of height then.

edit:

    <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical"     android:background="@drawable/background" >      <button         android:id="@+id/bnivoi1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center"         android:layout_margintop="80dp"         android:background="@drawable/button_nivoi_back" />      <linearlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:weightsum="1"         android:orientation="horizontal" >      <textview         android:id="@+id/tvopis15nivoa"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_gravity="center"         android:gravity="center"         android:textsize="15sp"         android:layout_weight="0.8"         android:text="text" />     </linearlayout>  </linearlayout> 

i need textview 80% of screen, not rest of activity.

android:layout_weight based on android:orientation of linearlayout - if want layout take 80% of width, need linearlayout android:orientation="horizontal"

<linearlayout     android:id="@+id/your_outer_layout"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:orientation="vertical" > <!-- note vertical 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> 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -