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 ??

table row

image view

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

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -