android - How to dynamically increase size of a relative layout based on length of text? -


i've relative view such this:

<?xml version="1.0" encoding="utf-8"?> <framelayout xmlns:android="http://schemas.android.com/apk/res/android"      android:id="@+id/linkcardview"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:background="@layout/login_gradient_bg"         >      <relativelayout         android:layout_width="match_parent"         android:layout_height="wrap_content"          android:layout_marginleft="6dp"         android:layout_marginright="6dp"         android:layout_margintop="4dp"         android:layout_marginbottom="4dp"         android:background="@drawable/card_bg">          <textview             android:id="@+id/linktitle0001"             android:layout_width="fill_parent"             android:layout_height="wrap_content"             android:layout_torightof="@+id/faviconview0001"             android:paddingleft="4dp"             android:linespacingextra="-2dp"             android:fontfamily="sans-serif-condensed"             android:maxlines="2"             android:text="@string/link_title_001"             android:textcolor="#717171"             android:textsize="17sp" />          <textview             android:id="@+id/linkdesc0001"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_below="@+id/faviconview0001"             android:paddingbottom="4dp"             android:fontfamily="sans-serif"             android:maxlines="1"             android:text="@string/link_desc_001"             android:textcolor="#acacac"             android:textsize="13sp"   />          <imageview             android:id="@+id/faviconview0001"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:paddingtop="6dp"             android:paddingbottom="7dp"             android:src="@drawable/favicon_example" />          <imageview             android:id="@+id/labelsource0001"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_below="@+id/linkdesc0001"             android:background="@drawable/card_label" />           </relativelayout>  </framelayout> 

i wanted increase size of relativelayout, length of text filled in linktitle0001 textview. how achieve that?

try this:  <?xml version="1.0" encoding="utf-8"?> <framelayout xmlns:android="http://schemas.android.com/apk/res/android"      android:id="@+id/linkcardview"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:background="@layout/login_gradient_bg"         >      <relativelayout         android:layout_width="match_parent"         android:layout_height="wrap_content"          android:layout_marginleft="6dp"         android:layout_marginright="6dp"         android:layout_margintop="4dp"         android:layout_marginbottom="4dp"         android:background="@drawable/card_bg">          <imageview             android:id="@+id/faviconview0001"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:paddingtop="6dp"             android:paddingbottom="7dp"             android:src="@drawable/favicon_example" />           <textview             android:id="@+id/linktitle0001"             android:layout_width="fill_parent"             android:layout_height="wrap_content"             android:layout_torightof="@+id/faviconview0001"             android:paddingleft="4dp"             android:linespacingextra="-2dp"             android:fontfamily="sans-serif-condensed"             android:maxlines="2"             android:text="@string/link_title_001"             android:textcolor="#717171"             android:textsize="17sp" />          <textview             android:id="@+id/linkdesc0001"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_below="@+id/faviconview0001"             android:paddingbottom="4dp"             android:fontfamily="sans-serif"             android:maxlines="1"             android:text="@string/link_desc_001"             android:textcolor="#acacac"             android:textsize="13sp"   />           <imageview             android:id="@+id/labelsource0001"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_below="@+id/linkdesc0001"             android:background="@drawable/card_label" />      </relativelayout>  </framelayout>  textview linktitle0001, try put below or align baseline per need. 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -