嘿,伙计们,我正在开发一个应用程序的屏幕出现问题。当我点击确定按钮时,ImageButton(btnSelect)应该设置可见性(GONE)并且应该出现ImageView(OkIcon),但是这会缩小EditText的空间,正如您在这些屏幕截图中看到的那样。Android:TableLayout在设置时发生变化View的setVisibility(可见)
http://imageshack.us/photo/my-images/17/problem1ei.png/
http://imageshack.us/photo/my-images/852/problem2m.png/
这究竟是为什么?
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);
}
布局的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> (...)
没有实际解决马上,但使用layout_weight我能够设置它,我想要的方式...非常感谢你 – 2011-05-23 18:20:00