我已经在 android 中制作了一个简单的对话框程序,用于登录对话框,用于学习目的。我已经成功制作并成功运行它,但唯一的问题是我想要一个图像作为整个对话框背景,但它也显示一个白色边框默认图像..我添加了屏幕截图,以便您了解...我的代码如下:
我的代码是:
对话框.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
android:orientation="vertical"
android:layout_gravity="center" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/dialoguebox"
android:padding="50dp"
>
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Login"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="@+id/usernm"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@drawable/bg_editext"
android:gravity="center"
android:hint="User name" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/pwd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@drawable/bg_editext"
android:gravity="center"
android:hint="Password"
android:inputType="textPassword" />
<CheckBox
android:id="@+id/chk_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remember me" />
<Button
android:id="@+id/login"
android:layout_width="fill_parent"
android:layout_height="32dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp"
android:background="@drawable/btn_small"
android:gravity="center"
android:text="Login"
android:textColor="#f6f1eb"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
对话代码
final Dialog dialog = new Dialog(Registration.this);
// Remove title bar
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.login_dialog);
final EditText UserName = (EditText) dialog
.findViewById(R.id.usernm);
final EditText Password = (EditText) dialog
.findViewById(R.id.pwd);
Button login = (Button) dialog.findViewById(R.id.login);
login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// dialog.dismiss();
String usr = UserName.getText().toString();
String pwd = Password.getText().toString();
Intent i =new Intent(Registration.this,ProgressActivity.class);
startActivity(i);
}
});
dialog.show();
break;