Android用のバージョン17(Galaxy Nexusを使用)でUIを開発していますが、背景が白になりました。バージョン15(Galaxy IIを使用)で同じコードを試すと、背景が黒くなります。では、なぜ同じコードなのに色が違うのでしょうか??
別の質問は、関数 setBackground を TextView に使用していたことです。これは、バージョン 16 以降専用です。setBackgroundResourse は同等ですか?
これは、コードを作成している例です。
FrameLayout frame = new FrameLayout(this);
frame.setId(findId());
FrameLayout.LayoutParams frameParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,FrameLayout.LayoutParams.MATCH_PARENT);
frame.setBackgroundResource(idBorder);
frame.setLayoutParams(frameParams);
//Relative layaout que engloba todo
RelativeLayout relativeLayout = new RelativeLayout(this);
//relativeLayout.setId(findId());
RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
relativeLayout.setLayoutParams(relativeParams);
relativeLayout.setPadding(5, 5, 5, 5);
relativeParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
relativeParams.addRule(RelativeLayout.CENTER_VERTICAL);
relativeLayout.setBackgroundColor(Color.WHITE);
//relativeLayout.setBackground(getResources().getDrawable(idBorder));
relativeLayout.setBackgroundResource(idBorder);
frame.addView(relativeLayout);
//Nombre de la sala
TextView textRoomName = new TextView(this);
textRoomName.setId(findId());
relativeLayout.addView(textRoomName);
textRoomName.setText(room.getName());
RelativeLayout.LayoutParams relativeParamRoomName = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
relativeParamRoomName.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
relativeParamRoomName.setMargins(10, 10, 10, 5);
textRoomName.setLayoutParams(relativeParamRoomName);
textRoomName.setTextColor(Color.parseColor("#040404"));
textRoomName.setTextSize(20);
textRoomName.setTypeface(null, Typeface.BOLD);
textRoomName.setPadding(3, 3, 3, 3);
//textRoomName.setBackground(getResources().getDrawable(idBorder));
textRoomName.setBackgroundResource(idBorder);