android - Problems with "ImageView cell width" on tablelayout -
i'm having troubles when tray insert images in tablerow of tablelayout.
the first imageview expands width of own cell , next images expands rest of row
how can divide de row in 5 cells equal size?
this snapshot of app
http://i41.tinypic.com/2dv77g6.png
this code of xml layout
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/gradient" android:gravity="center" android:orientation="vertical" > <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginright="15dp" android:layout_margintop="5dp" android:layout_weight="1" android:gravity="center_vertical|right" android:orientation="horizontal" > <imageview android:id="@+id/user" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="5dp" android:contentdescription="@string/es_user" android:gravity="right" android:src="@drawable/user" /> <textview android:id="@+id/textuser" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="@string/es_user" android:textcolor="#ffffff" android:textsize="16sp" android:textstyle="bold" /> <textview android:id="@+id/user" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="" android:textcolor="#ffffff" android:textsize="16sp" /> <textview android:id="@+id/textlogout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="@string/es_logout" android:textcolor="#fc0505" android:textsize="16sp" android:textstyle="bold" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="5" android:gravity="center" > <tablelayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center|center_horizontal" android:background="@drawable/roundcorners" android:paddingbottom="20dp" android:paddingleft="30dp" android:paddingright="30dp" android:paddingtop="20dp" > <tablerow android:layout_weight="1" > <imageview android:id="@+id/logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center|center_horizontal" android:layout_weight="0.5" android:contentdescription="@string/es_logo" android:paddingright="25dp" android:src="@drawable/logotra" /> <tablelayout android:layout_width="wrap_content" android:layout_gravity="center_horizontal" android:layout_weight="0.5" > <tablerow android:layout_weight="1" > <textview android:id="@+id/textpatient" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="left" android:layout_weight="1" android:text="@string/es_codpatient" android:textcolor="#000000" android:textsize="15sp" /> </tablerow> <tablerow android:layout_width="wrap_content" android:layout_weight="1" > <edittext android:id="@+id/txtcodpatient" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:inputtype="text" /> </tablerow> <tablerow android:layout_width="match_parent" android:layout_marginbottom="10dp" android:layout_margintop="5dp" android:layout_weight="1" > <imageview android:id="@+id/eslanguagebtn" android:layout_width="wrap_content" android:layout_marginright="10dp" android:layout_weight="0.166" android:src="@drawable/esp" /> <imageview android:id="@+id/enlanguagebtn" android:layout_width="wrap_content" android:layout_marginright="10dp" android:layout_weight="0.166" android:src="@drawable/en" /> <imageview android:id="@+id/catlanguagebtn" android:layout_width="wrap_content" android:layout_marginright="10dp" android:layout_weight="0.166" android:src="@drawable/cat" /> <imageview android:id="@+id/galanguagebtn" android:layout_width="wrap_content" android:layout_marginright="10dp" android:layout_weight="0.166" android:src="@drawable/ga" /> <imageview android:id="@+id/eulanguagebtn" android:layout_width="wrap_content" android:layout_marginright="10dp" android:layout_weight="0.166" android:src="@drawable/eusk" /> <imageview android:id="@+id/ptlanguagebtn" android:layout_width="wrap_content" android:layout_marginright="10dp" android:layout_weight="0.166" android:src="@drawable/por" /> </tablerow> <tablerow android:layout_weight="1" android:gravity="center" > <button android:id="@+id/btnstart" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0.5" android:text="@string/es_start" /> </tablerow> </tablelayout> </tablerow> </tablelayout> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginright="10dp" android:layout_weight="1" android:gravity="center|right" > <textview android:id="@+id/large_appname" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/es_large_appname" android:textcolor="#ffffff" android:textsize="20sp" android:textstyle="bold" /> </linearlayout> </linearlayout>
try set layout of 5 country images below:
as giving each imageview
weight best result must have give width of imageview
0dp
.
replace 5 country code below code , check out.
<tablerow android:layout_width="fill_parent" android:layout_marginbottom="10dp" android:layout_margintop="5dp" android:layout_weight="1" > <imageview android:id="@+id/eslanguagebtn" android:layout_width="0dp" android:layout_marginright="10dp" android:layout_weight="0.166" android:background="@drawable/icon" /> <imageview android:id="@+id/enlanguagebtn" android:layout_width="0dp" android:layout_marginright="10dp" android:layout_weight="0.166" android:src="@drawable/icon" /> <imageview android:id="@+id/catlanguagebtn" android:layout_width="0dp" android:layout_marginright="10dp" android:layout_weight="0.166" android:src="@drawable/icon" /> <imageview android:id="@+id/galanguagebtn" android:layout_width="0dp" android:layout_marginright="10dp" android:layout_weight="0.166" android:src="@drawable/icon" /> <imageview android:id="@+id/eulanguagebtn" android:layout_width="0dp" android:layout_marginright="10dp" android:layout_weight="0.166" android:src="@drawable/icon" /> <imageview android:id="@+id/ptlanguagebtn" android:layout_width="0dp" android:layout_marginright="10dp" android:layout_weight="0.166" android:src="@drawable/icon" /> </tablerow>
let me know if still problem.
thanks.
Comments
Post a Comment