在Android中,當我們顯示諸如提示對話框,進度對話框,打開抽屜等內容時,看起來我們在屏幕上有一個透明的黑色圖層,然後是一種對話框中,像這樣的圖片:如何更改Android對話框或抽屜菜單中的黑色
我的目標是改變透明的黑色層,而不是對話的背景,看到這樣的畫面:
如何這個透明的黑色層的顏色更改爲類似紅色還是任何顏色?例如,在XML或Java代碼
這是我MyExitDialog類代碼
public class MyExitDialog extends Dialog implements android.view.View.OnClickListener
{
DatabaseHandler userDB;
public Activity c;
public Dialog d;
public Button yes, no;
public MyExitDialog(Activity a)
{
super(a);
this.c = a;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.mydialog);
yes = (Button) findViewById(R.id.id_exit_yes);
no = (Button) findViewById(R.id.id_exit_no);
yes.setOnClickListener(this);
no.setOnClickListener(this);
}
@Override
public void onClick(View v)
{
switch (v.getId()) {
case R.id.id_exit_yes:
//c.finish();
DrawerActivity.userDB=new DatabaseHandler(MyExitDialog.this.getContext());
DrawerActivity.userDB.open();
DrawerActivity.userDB.logOut();
DrawerActivity.userDB.close();
DrawerActivity.changeDrawerItems("logout");
break;
case R.id.id_exit_no:
dismiss();
break;
default:
break;
}
dismiss();
}
}
,這是我如何使用:
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
Fragment myFragment = null;
View myView;
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/BYekan.ttf");
if (id == R.id.nav_home) {
} else if (id == R.id.nav_register) {
} else if (id == R.id.nav_change) {
} else if (id == R.id.nav_login) {
} else if (id == R.id.nav_factors) {
} else if (id == R.id.nav_logout) {
MyExitDialog myDialog = new MyExitDialog(DrawerActivity.this);
myDialog.show();
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
這是什麼'背景:@色/ newbg'? – UmarZaii
@UmarZaii這只是一個提示 – Fanous
在文章中加入對話代碼 – UmarZaii