android - Set Width of Fragment as a percentage of screen Width -


i have fragment need span bottom top of screen, , left edge 80% of screen.

i've tried using android:layout_weight="0.8" 'invalid layout parameter' message, when nest <fragment> in <relativelayout> or <linearlayout>

right now, height spans top bottom, because of android:layout_height="fill_parent" width still set wrap_content because have no idea how set 80% of screen width.

<fragment         android:layout_width="wrap_content"         android:layout_height="fill_parent"         android:id="@+id/xfragment"         android:name="com.example.x.x.xfragment"/> 

thank you

put fragment in linear layout, this:

<linearlayout android:layout_width="match_parent"                android:layout_height="match_parent"               android:orientation="horizontal"               android:weightsum="10">      <fragment             android:layout_width="0dp"             android:layout_weight="8"             android:layout_height="fill_parent"             android:id="@+id/xfragment"             android:name="com.example.x.x.xfragment"/>        <view             android:id="@+id/otherelement"             android:layout_width="0dp"             android:layout_height="match_parent"             android:layout_weight="2"/>  </linearlayout> 

hope helps you!!


Comments