Reputation: 17
I try to make a image button for login. But the result is weird. Please see the attachment.
The weird thing is the image button is inside the button...
Hope for helps.
this is xml code...
<ImageButton
android:id="@+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/chkRememberMe"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:src="@drawable/login_off" />
this is java code for the login button...
imageButtonLogin = (ImageButton) findViewById(R.id.loginButton);
imageButtonLogin.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String inputPassword = passwordEditText.getText().toString();
if (password.isEmpty()) {
showDialog(DIALOG_ALERT);
} else {
String inputUserName = userNameEditText.getText()
.toString();
Contact contact = new Contact();
contact.setUsername(inputUserName);
contact.setPassword(inputPassword);
if (contactDb.searchContact(contact)) {
// logged in
/*Toast.makeText(getApplicationContext(),
getResources().getString(R.string.loggedIn),
Toast.LENGTH_LONG).show();*/
Intent newActivity = new Intent();
//go to AudioRecoder page
newActivity
.setClass(MainActivity.this, AudioActivity.class);
startActivity(newActivity);
} else {
// login failed
showDialog(DIALOG_ALERT);
}
}
}
Upvotes: 0
Views: 135
Reputation: 157447
<ImageButton
android:id="@+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/chkRememberMe"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:background="@null"
android:src="@drawable/login_off" />
you can set the background or trasparent android:background="#00FFFFFF"
or to null android:background="@null"
Upvotes: 0
Reputation: 46856
You need to use
android:background="@drawable/login_off"
instead of src like you are.
Upvotes: 1