android - ImageView not getting width -
i have following xml code:
<tablelayout android:layout_width="match_parent" android:layout_height="wrap_content"> <tablerow android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center"> <imageview android:id="@+id/imgoffer" android:layout_width="match_parent" android:layout_height="200dp" android:scaletype="fitxy" app:srccompat="@drawable/applogo1" /> </tablerow> </tablelayout> according code, imgoffer should entire width of it's parent tablerow
but image width not changing ( see images below )
it works fine when hard-code width (say 150dp)
what doing wrong here ??
this seems solve it, use weight instead of width:
<imageview android:id="@+id/imgoffer" android:layout_weight="1" android:layout_height="200dp" android:scaletype="fitxy" app:srccompat="@drawable/applogo1" /> source tablelayout layout_width=matchparent not matching parent


Comments
Post a Comment