android - Set TextView width according to other View's width -
i have imageview
, image loaded net , can vary in width. below have textview
description of image. want textview
wide imageview
.
my try this:
<linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:orientation="vertical" > <imageview android:id="@+id/iv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" /> <textview android:id="@+id/imagedescription" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:textappearance="@style/smalltextgray" /> </linearlayout>
which somehow works textview
's width set accoring of imageview
, textview
end after 2 lines:
i know set textview
's width programmatically after know image's width, there way in xml layout?
i don't know if work, try doing in code, after load image:
textview.setwidth(imageview.getdrawable().getintrinsicwidth());
Comments
Post a Comment