android edittext背景颜色,Android:在改变EditText背景颜色时,EditText样式发生了变化...

嗨当我更改两个EditText的EditText的背景颜色时,它们看起来像两个合并.

我的布局代码就像这样`

android:id="@+id/editText4"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:ems="10"

android:hint="Text1"

android:singleLine="true" />

android:id="@+id/editText1"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:ems="10"

android:hint="Text2"

android:singleLine="true" >

android:layout_height="wrap_content"

android:singleLine="true"

android:imeOptions="actionNext"/>

android:layout_width="fill_parent"

android:layout_height="wrap_content" >

android:id="@+id/editText2"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:ems="10"

android:hint="Text3"

android:singleLine="true" />

android:layout_width="fill_parent"

android:layout_height="wrap_content" >

android:id="@+id/editText2"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:ems="10"

android:hint="Text4"

android:singleLine="true" />

android:id="@+id/button1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Button" />

`

和我的活动代码是这样的

public class MainActivity extends Activity {

EditText editText1, editText2, editText3, editText4;

Button button;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

init();

button.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View v) {

editText1.setBackgroundColor(getResources().getColor(android.R.color.primary_text_dark_nodisable));

editText3.setBackgroundColor(getResources().getColor(android.R.color.darker_gray));

}

});

}

private void init() {

editText1 = (EditText) findViewById(R.id.editText1);

editText2 = (EditText) findViewById(R.id.editText2);

editText3 = (EditText) findViewById(R.id.editText4);

button = (Button) findViewById(R.id.button1);

}

}

请参阅下面的屏幕截图

单击按钮之前的布局

单击按钮后的布局

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值