Hey guys, I’m having some trouble with a screen from the app I’m developing. When I click the OK button, the ImageButton (btnSelect) should setVisibility(GONE) and the ImageView (OkIcon) should appear, but this shrinks the space for the EditText as you can see in those screen shots.
http://imageshack.us/photo/my-images/17/problem1ei.png/
http://imageshack.us/photo/my-images/852/problem2m.png/
Why is this happening?
CODE:
@Override
public void onClick(View v) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (v.getId() == R.id.init_select1) {
if (validateSal(this.edtTextInit1.getText().toString())) {
saveSal(this.edtTextInit1.getText().toString());
imm.hideSoftInputFromWindow(edtTextInit1.getWindowToken(),0);
edtTextInit1.setEnabled(false);
btnSelect1.setVisibility(View.GONE);
okIcon1.setVisibility(View.VISIBLE);
btnSelect2.setVisibility(View.VISIBLE);
}
LAYOUT’S XML:
<ScrollView
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<TableLayout
android:gravity="center"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_weight="1"
android:shrinkColumns="0">
<TableRow>
<TextView
style="@style/styleTextLabel"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/label_init"
android:id="@+id/label_init"
android:layout_margin="10dip">
</TextView>
</TableRow>
<TableRow>
<EditText
android:layout_column="0"
android:layout_marginRight="10dip"
android:layout_marginLeft="10dip"
android:layout_marginBottom="10dip"
style="@style/styleInputInit"
android:id="@+id/input_init1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</EditText>
<ImageView
android:visibility="gone"
android:layout_marginRight="10dip"
android:layout_marginLeft="10dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/okicon"
android:id="@+id/init_ok1">
</ImageView>
<ImageButton
android:layout_column="1"
android:layout_marginRight="10dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/init_select1"
android:background="@drawable/btn_ok_">
</ImageButton>
</TableRow>
<TableRow>
<EditText
android:layout_column="0"
android:layout_marginRight="10dip"
android:layout_marginLeft="10dip"
android:layout_marginBottom="10dip"
android:id="@+id/input_init2"
style="@style/styleInputInit"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</EditText>
<ImageView
android:layout_column="1"
android:visibility="gone"
android:layout_marginRight="10dip"
android:layout_marginLeft="10dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/okicon"
android:id="@+id/init_ok2">>
</ImageView>
<ImageButton
android:layout_column="1"
android:layout_marginRight="10dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/init_select2"
android:background="@drawable/btn_ok_"
android:visibility="gone">
</ImageButton>
</TableRow> (...)
Try to put weight on EditText like: