android - Set ImageView from SDcard to match_parent height? -
so have actiondialog
saves signature. when set imageview
new captured signature way tall. below illustrate problem
right @ default screen looks this
(textview)-(--edittext--)-(space)-
(textview)-(--edittext--)-(space)-
(textview)-(imageview)-(button)-
after user clicks button asks signature, saves signature, replaces default imageview
new bitmap
. ends looking this
(textview)-(--edittext--)-(space)-
(textview)-(--edittext--)-(space)-
(textview)-(imageview)-(button)-
i'm unsure why happening. here xml layout
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/twoglobe_line" android:gravity="center" android:orientation="vertical" > <linearlayout android:id="@+id/sigll3" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <textview android:id="@+id/textview3" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:text="@string/title" android:textappearance="?android:attr/textappearancesmall" /> <edittext android:id="@+id/edittext2" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="2" android:ems="10" > <requestfocus /> </edittext> <space android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" /> </linearlayout> <linearlayout android:id="@+id/sigll1" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <textview android:id="@+id/textview1" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:text="@string/print_name" android:textappearance="?android:attr/textappearancesmall" /> <edittext android:id="@+id/edittext1" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="2" android:ems="10" > <requestfocus /> </edittext> <space android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" /> </linearlayout> <linearlayout android:id="@+id/sigll2" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <textview android:id="@+id/textview2" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:text="@string/signature" android:textappearance="?android:attr/textappearancesmall" /> <imageview android:id="@+id/sig_image" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="2" android:src="@drawable/sig" /> <button android:id="@+id/signature" style="?android:attr/borderlessbuttonstyle" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="@string/sign" /> </linearlayout> </linearlayout> </scrollview>
i make new bitmap
same height button
, textview
next it. or as possible. can offer
use pixels scale image according textview or whatever per device, scale bitmap accordingly
public static int dptopixels(context context, float dp) { final float scale = context.getresources().getdisplaymetrics().density; return (int) (dp * scale + 0.5f); }
then in code after this
bitmap bmp = bitmapfactory.decodefile(mysig .getabsolutepath()); bmp = bitmap.createscaledbitmap(bmp,bmp.getwidth(),dptopixels(this,20)); //or dp
Comments
Post a Comment