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:

enter image description here

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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -