How to set the image in button in android -
i have problem while working in android , , setting image in button. have image want set in button have multiple resolution of button image different buckets support multiple screen sizes .
following image , having resolution of 85*85
now when want set in button got image screw slightly. seems image in width larger image in height not in reality. let me share picture after setting image in button. screen short of android samsung galaxy s4 device xxhd device
now can see how bad looking .
this how setting in xml
<button android:id="@+id/btn_flip_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:src="@drawable/flip_image" />
but when set image in imageview every thing looks great expected. problem not in image nor in xml way in using button . can 1 tell me best way of using image in button or in imagebutton .
please tell me why happen time when try set image in button , whereas in end when use imageview desired results.
(how ever using imageview make me loose touch effect button has naturally , default.)
**edit1 ** here part of xml using buttons
<linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="left|top" android:layout_marginleft="5dp" android:layout_margintop="10dp" android:orientation="vertical" android:background="@drawable/menu_bg" android:paddingleft="5dp" android:paddingright="5dp" android:gravity="center" > <button android:id="@+id/btn_flip_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:background="@drawable/flip_image" /> <textview android:layout_width="match_parent" android:layout_height="5dp" /> <button android:id="@+id/btn_flip_suit" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:background="@drawable/flip_suit" /> <textview android:layout_width="match_parent" android:layout_height="5dp" /> <button android:id="@+id/btn_change_suit" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:background="@drawable/change_suit" /> <textview android:layout_width="match_parent" android:layout_height="5dp" /> <button android:id="@+id/btn_share" android:layout_width="wrap_content" android:layout_gravity="center" android:layout_height="wrap_content" android:background="@drawable/share_btn" /> <textview android:layout_width="match_parent" android:layout_height="5dp" /> <button android:id="@+id/btn_save" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:background="@drawable/save_image" /> </linearlayout>
so 1 please make me understand doing wrong or best way of using button custom image. ??
i have tested code, there no problem in it...
as image width problem, due screen resolution on different devices, can put linear layout
in scrollview
your code output before scrollview :
<scrollview android:layout_width="wrap_content" android:layout_height="wrap_content"> //---your code ----// <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="left|top" android:layout_marginleft="5dp" android:layout_margintop="10dp" android:orientation="vertical" android:background="#000000" android:paddingleft="5dp" android:paddingright="5dp" android:gravity="center" > <button android:id="@+id/btn_flip_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:background="@drawable/flip" /> //-----// </linearlayout> </scrollview>
your output after scrollview :
Comments
Post a Comment