android - Image view to stretch fit table row width -


i have layout xml want imageview in second row stretch fit row view if possible , textview in first row stuck on left of screen , need in center. imageview being filled image taken camera, appreciated.

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" >  <tablelayout     android:layout_width="match_parent"     android:layout_height="0dp"     android:layout_gravity="center"     android:layout_weight="1"     android:stretchcolumns="*" >      <tablerow android:id="@+id/tablerow1" >          <linearlayout             android:layout_width="0dp"             android:layout_height="wrap_content"             android:layout_weight="1" >              <textview                 android:id="@+id/textview1"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:layout_weight="1"                 android:layout_gravity="center"                 android:text="set personal information here"                 android:textappearance="?android:attr/textappearancemedium" />         </linearlayout>     </tablerow>      <tablerow android:id="@+id/tablerow2" >          <linearlayout             android:layout_width="0dp"             android:layout_height="wrap_content"             android:layout_weight="1" >              <imageview                 android:id="@+id/imageview1"                 android:layout_width="match_parent"                 android:layout_height="match_parent" />         </linearlayout>     </tablerow>      <tablerow android:id="@+id/tablerow3" >          <linearlayout             android:layout_width="0dp"             android:layout_height="wrap_content"             android:layout_weight="1"             android:orientation="horizontal" >              <quickcontactbadge                 android:id="@+id/quickcontactbadge1"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_gravity="left" />              <linearlayout                 android:layout_width="wrap_content"                 android:layout_height="match_parent"                 android:orientation="vertical" >                  <textview                     android:id="@+id/textview2"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:text="name"                     android:textappearance="?android:attr/textappearancemedium" />                  <textview                     android:id="@+id/textview3"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:text="gender"                     android:textappearance="?android:attr/textappearancemedium" />                  <textview                     android:id="@+id/textview4"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:text="credits"                     android:textappearance="?android:attr/textappearancemedium" />             </linearlayout>         </linearlayout>     </tablerow> </tablelayout> 

as @brosa said in comment, use android:scaletype="fitxy" attribute.

althrough have find solution, writing answer write brief description different option of android:scaletype future help.

there several options in attreibute.

  1. matrix
  2. fitxy
  3. fitstart
  4. fitcenter
  5. fitend
  6. center
  7. centercrop
  8. centerinside

here small description doc

1. matrix
scale using image matrix when drawing.

2. fitxy
scale image in x , y independently, src matches dst exactly. may change aspect ratio of src.

3. fitstart
scale image computing scale maintain original src aspect ratio, ensure src fits entirely inside dst. @ least 1 axis (x or y) fit exactly. start aligns result left , top edges of dst.

4. fitcenter
scale image computing scale maintain original src aspect ratio, ensure src fits entirely inside dst. @ least 1 axis (x or y) fit exactly. result centered inside dst.

5. fitend
scale image computing scale maintain original src aspect ratio, ensure src fits entirely inside dst. @ least 1 axis (x or y) fit exactly. end aligns result right , bottom edges of dst.

6. center
center image in view, perform no scaling.

7. centercrop
scale image uniformly (maintain image's aspect ratio) both dimensions (width , height) of image equal or larger corresponding dimension of view (minus padding).

8. centerinside
scale image uniformly (maintain image's aspect ratio) both dimensions (width , height) of image equal or less corresponding dimension of view (minus padding).


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 -