Button inside Relative Layout not responding to Clicks
I have been coding for android for a little while now but recently i encountered an issue that is driving me crazy. I have some child items inside relativeLayout
that i want to assign some click events. However, these buttons are not responding to click events and i don't get any error. I have surfed the net for solution but haven't found any. Please help.
LoginActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LoginActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/bg_image"/>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.65"
android:background="@android:color/black"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/relativeHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:alpha="0.8"
android:layout_gravity="center_horizontal|top">
<ImageView
android:id="@+id/img_logo"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="30dp"
android:layout_centerHorizontal="true"
android:src="@drawable/card"/>
<TextView
android:id="@+id/meet_me_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/img_logo"
android:layout_centerHorizontal="true"
android:text="@string/text"
android:textColor="@android:color/white"
android:textSize="35sp"
android:textStyle="bold"
app:fontFamily="@font/dancing_script_bold" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/email_signup_btn"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:textSize="14sp"
android:textColor="@drawable/login_text_selector"
android:textAllCaps="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sign_up_with_email"
android:background="@drawable/button_bg"/>
<Button
android:id="@+id/signin_btn"
android:layout_below="@+id/email_signup_btn"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:textColor="@drawable/login_text_selector"
android:layout_marginBottom="20dp"
android:textSize="14sp"
android:textAllCaps="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sign_in"
android:background="@drawable/button_bg2"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout2"
android:visibility="invisible"
android:layout_marginTop="20dp"
android:layout_below="@+id/relativeHeader"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/username_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/username"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/username_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="26dp"
android:layout_below="@+id/username_text"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/username_editText"
android:textColor="@android:color/white"
android:inputType="text"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/password_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/username_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/password"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/password_input_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="10dp"
app:passwordToggleTint="@android:color/white"
android:layout_below="@+id/password_text"
app:passwordToggleEnabled="true">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/password_editText"
android:inputType="textPassword"
android:textColor="@android:color/white"
app:backgroundTint="@android:color/white"
android:textCursorDrawable="@drawable/edit_text_cursor"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/forgot_pass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/password_input_text"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="10dp"
android:text="@string/forgot_your_password"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<Button
android:id="@+id/login_btn"
android:layout_below="@+id/forgot_pass"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:textSize="14sp"
android:textColor="@drawable/login_text_selector"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sign_in"
android:background="@drawable/button_bg"/>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="18dp"
android:layout_marginBottom="20dp"
android:layout_below="@+id/relativeHeader">
<RelativeLayout
android:id="@+id/relativeLayout3"
android:layout_width="match_parent"
android:visibility="invisible"
android:layout_height="wrap_content">
<TextView
android:id="@+id/username_reg_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/username"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/username_reg_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="18dp"
app:hintEnabled="false"
android:layout_below="@+id/username_reg_text"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/username_reg_editText"
android:textColor="@android:color/white"
android:inputType="text"
android:textColorHint="@android:color/white"
android:hint="@string/edittext_hint_username"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/email_reg_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/username_reg_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/email"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/email_reg_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="18dp"
app:hintEnabled="false"
android:layout_below="@+id/email_reg_text"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/email_reg_editText"
android:textColor="@android:color/white"
android:inputType="text"
android:textColorHint="@android:color/white"
android:hint="@string/edittext_hint_email"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/phone_reg_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/email_reg_input_text"
android:textColor="@android:color/white"
android:textSize="16sp"
android:text="@string/phone"/>
<LinearLayout
android:id="@+id/phone_reg_input_text_layout"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/phone_reg_text"
android:gravity="center_vertical">
<com.hbb20.CountryCodePicker
android:id="@+id/ccp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:ccp_textSize="14sp"
app:ccp_contentColor="@android:color/white"
app:ccp_countryPreference="us,ng"/>
<android.support.design.widget.TextInputLayout
android:id="@+id/phone_reg_input_text"
app:hintEnabled="false"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/phone_reg_editText"
android:textColor="@android:color/white"
android:inputType="text"
android:background="@android:color/transparent"
android:textColorHint="@android:color/white"
android:hint="@string/edittext_hint_phone"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<View
android:id="@+id/bottom_border"
android:layout_marginBottom="18dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_below="@+id/phone_reg_input_text_layout"
android:background="@android:color/white"
android:layout_height="1.5dp"
android:layout_width="fill_parent"/>
<TextView
android:id="@+id/pass_reg_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/bottom_border"
android:textColor="@android:color/white"
android:textSize="16sp"
android:text="@string/password"/>
<android.support.design.widget.TextInputLayout
android:id="@+id/pass_reg_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="10dp"
app:hintEnabled="false"
app:passwordToggleEnabled="true"
app:passwordToggleTint="@android:color/white"
android:layout_below="@+id/pass_reg_text"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/pass_reg_editText"
android:textColor="@android:color/white"
android:inputType="textPassword"
android:textColorHint="@android:color/white"
android:hint="@string/edittext_hint_pass"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/register_btn"
android:layout_below="@+id/pass_reg_input_text"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:textSize="14sp"
android:textColor="@drawable/login_text_selector"
android:textAllCaps="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/register"
android:background="@drawable/button_bg"/>
</RelativeLayout>
</ScrollView>
<RelativeLayout
android:id="@+id/relativeLayout4"
android:layout_marginTop="10dp"
android:layout_below="@+id/relativeHeader"
android:visibility="invisible"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/email_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/email"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/retrieve_email_input_text"
app:hintEnabled="false"
android:layout_marginTop="8dp"
android:padding="12dp"
app:passwordToggleTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/retrieve_email_editText"
android:textColor="@android:color/white"
android:textColorHint="@android:color/white"
android:inputType="text"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/retrieve_pass_btn"
android:layout_below="@+id/retrieve_email_input_text"
android:layout_centerHorizontal="true"
android:layout_margin="16dp"
android:textSize="14sp"
android:textColor="@drawable/login_text_selector"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/send"
android:background="@drawable/button_bg"/>
</RelativeLayout>
</RelativeLayout>
<Button
android:id="@+id/back_btn"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="30dp"
android:layout_marginLeft="16dp"
android:visibility="invisible"
android:layout_gravity="top|start"
android:background="@drawable/ic_arrow_back_black_24dp"
android:layout_marginStart="16dp" />
</RelativeLayout>
LoginActivity.java
signInBtn = findViewById(R.id.signin_btn);
signInBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
relativeLayout1.setVisibility(View.INVISIBLE);
relativeLayout2.setVisibility(View.VISIBLE);
backBtn.setVisibility(View.VISIBLE);
}
});
android xml
add a comment |
I have been coding for android for a little while now but recently i encountered an issue that is driving me crazy. I have some child items inside relativeLayout
that i want to assign some click events. However, these buttons are not responding to click events and i don't get any error. I have surfed the net for solution but haven't found any. Please help.
LoginActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LoginActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/bg_image"/>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.65"
android:background="@android:color/black"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/relativeHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:alpha="0.8"
android:layout_gravity="center_horizontal|top">
<ImageView
android:id="@+id/img_logo"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="30dp"
android:layout_centerHorizontal="true"
android:src="@drawable/card"/>
<TextView
android:id="@+id/meet_me_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/img_logo"
android:layout_centerHorizontal="true"
android:text="@string/text"
android:textColor="@android:color/white"
android:textSize="35sp"
android:textStyle="bold"
app:fontFamily="@font/dancing_script_bold" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/email_signup_btn"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:textSize="14sp"
android:textColor="@drawable/login_text_selector"
android:textAllCaps="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sign_up_with_email"
android:background="@drawable/button_bg"/>
<Button
android:id="@+id/signin_btn"
android:layout_below="@+id/email_signup_btn"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:textColor="@drawable/login_text_selector"
android:layout_marginBottom="20dp"
android:textSize="14sp"
android:textAllCaps="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sign_in"
android:background="@drawable/button_bg2"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout2"
android:visibility="invisible"
android:layout_marginTop="20dp"
android:layout_below="@+id/relativeHeader"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/username_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/username"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/username_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="26dp"
android:layout_below="@+id/username_text"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/username_editText"
android:textColor="@android:color/white"
android:inputType="text"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/password_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/username_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/password"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/password_input_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="10dp"
app:passwordToggleTint="@android:color/white"
android:layout_below="@+id/password_text"
app:passwordToggleEnabled="true">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/password_editText"
android:inputType="textPassword"
android:textColor="@android:color/white"
app:backgroundTint="@android:color/white"
android:textCursorDrawable="@drawable/edit_text_cursor"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/forgot_pass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/password_input_text"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="10dp"
android:text="@string/forgot_your_password"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<Button
android:id="@+id/login_btn"
android:layout_below="@+id/forgot_pass"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:textSize="14sp"
android:textColor="@drawable/login_text_selector"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sign_in"
android:background="@drawable/button_bg"/>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="18dp"
android:layout_marginBottom="20dp"
android:layout_below="@+id/relativeHeader">
<RelativeLayout
android:id="@+id/relativeLayout3"
android:layout_width="match_parent"
android:visibility="invisible"
android:layout_height="wrap_content">
<TextView
android:id="@+id/username_reg_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/username"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/username_reg_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="18dp"
app:hintEnabled="false"
android:layout_below="@+id/username_reg_text"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/username_reg_editText"
android:textColor="@android:color/white"
android:inputType="text"
android:textColorHint="@android:color/white"
android:hint="@string/edittext_hint_username"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/email_reg_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/username_reg_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/email"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/email_reg_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="18dp"
app:hintEnabled="false"
android:layout_below="@+id/email_reg_text"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/email_reg_editText"
android:textColor="@android:color/white"
android:inputType="text"
android:textColorHint="@android:color/white"
android:hint="@string/edittext_hint_email"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/phone_reg_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/email_reg_input_text"
android:textColor="@android:color/white"
android:textSize="16sp"
android:text="@string/phone"/>
<LinearLayout
android:id="@+id/phone_reg_input_text_layout"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/phone_reg_text"
android:gravity="center_vertical">
<com.hbb20.CountryCodePicker
android:id="@+id/ccp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:ccp_textSize="14sp"
app:ccp_contentColor="@android:color/white"
app:ccp_countryPreference="us,ng"/>
<android.support.design.widget.TextInputLayout
android:id="@+id/phone_reg_input_text"
app:hintEnabled="false"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/phone_reg_editText"
android:textColor="@android:color/white"
android:inputType="text"
android:background="@android:color/transparent"
android:textColorHint="@android:color/white"
android:hint="@string/edittext_hint_phone"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<View
android:id="@+id/bottom_border"
android:layout_marginBottom="18dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_below="@+id/phone_reg_input_text_layout"
android:background="@android:color/white"
android:layout_height="1.5dp"
android:layout_width="fill_parent"/>
<TextView
android:id="@+id/pass_reg_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/bottom_border"
android:textColor="@android:color/white"
android:textSize="16sp"
android:text="@string/password"/>
<android.support.design.widget.TextInputLayout
android:id="@+id/pass_reg_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="10dp"
app:hintEnabled="false"
app:passwordToggleEnabled="true"
app:passwordToggleTint="@android:color/white"
android:layout_below="@+id/pass_reg_text"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/pass_reg_editText"
android:textColor="@android:color/white"
android:inputType="textPassword"
android:textColorHint="@android:color/white"
android:hint="@string/edittext_hint_pass"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/register_btn"
android:layout_below="@+id/pass_reg_input_text"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:textSize="14sp"
android:textColor="@drawable/login_text_selector"
android:textAllCaps="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/register"
android:background="@drawable/button_bg"/>
</RelativeLayout>
</ScrollView>
<RelativeLayout
android:id="@+id/relativeLayout4"
android:layout_marginTop="10dp"
android:layout_below="@+id/relativeHeader"
android:visibility="invisible"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/email_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/email"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/retrieve_email_input_text"
app:hintEnabled="false"
android:layout_marginTop="8dp"
android:padding="12dp"
app:passwordToggleTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/retrieve_email_editText"
android:textColor="@android:color/white"
android:textColorHint="@android:color/white"
android:inputType="text"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/retrieve_pass_btn"
android:layout_below="@+id/retrieve_email_input_text"
android:layout_centerHorizontal="true"
android:layout_margin="16dp"
android:textSize="14sp"
android:textColor="@drawable/login_text_selector"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/send"
android:background="@drawable/button_bg"/>
</RelativeLayout>
</RelativeLayout>
<Button
android:id="@+id/back_btn"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="30dp"
android:layout_marginLeft="16dp"
android:visibility="invisible"
android:layout_gravity="top|start"
android:background="@drawable/ic_arrow_back_black_24dp"
android:layout_marginStart="16dp" />
</RelativeLayout>
LoginActivity.java
signInBtn = findViewById(R.id.signin_btn);
signInBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
relativeLayout1.setVisibility(View.INVISIBLE);
relativeLayout2.setVisibility(View.VISIBLE);
backBtn.setVisibility(View.VISIBLE);
}
});
android xml
Not sure that this is your problem, but you should be using "gone" rather than "invisible", in your layout and also in your code.
– lionscribe
Jan 20 at 5:44
add a comment |
I have been coding for android for a little while now but recently i encountered an issue that is driving me crazy. I have some child items inside relativeLayout
that i want to assign some click events. However, these buttons are not responding to click events and i don't get any error. I have surfed the net for solution but haven't found any. Please help.
LoginActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LoginActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/bg_image"/>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.65"
android:background="@android:color/black"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/relativeHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:alpha="0.8"
android:layout_gravity="center_horizontal|top">
<ImageView
android:id="@+id/img_logo"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="30dp"
android:layout_centerHorizontal="true"
android:src="@drawable/card"/>
<TextView
android:id="@+id/meet_me_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/img_logo"
android:layout_centerHorizontal="true"
android:text="@string/text"
android:textColor="@android:color/white"
android:textSize="35sp"
android:textStyle="bold"
app:fontFamily="@font/dancing_script_bold" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/email_signup_btn"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:textSize="14sp"
android:textColor="@drawable/login_text_selector"
android:textAllCaps="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sign_up_with_email"
android:background="@drawable/button_bg"/>
<Button
android:id="@+id/signin_btn"
android:layout_below="@+id/email_signup_btn"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:textColor="@drawable/login_text_selector"
android:layout_marginBottom="20dp"
android:textSize="14sp"
android:textAllCaps="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sign_in"
android:background="@drawable/button_bg2"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout2"
android:visibility="invisible"
android:layout_marginTop="20dp"
android:layout_below="@+id/relativeHeader"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/username_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/username"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/username_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="26dp"
android:layout_below="@+id/username_text"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/username_editText"
android:textColor="@android:color/white"
android:inputType="text"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/password_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/username_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/password"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/password_input_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="10dp"
app:passwordToggleTint="@android:color/white"
android:layout_below="@+id/password_text"
app:passwordToggleEnabled="true">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/password_editText"
android:inputType="textPassword"
android:textColor="@android:color/white"
app:backgroundTint="@android:color/white"
android:textCursorDrawable="@drawable/edit_text_cursor"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/forgot_pass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/password_input_text"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="10dp"
android:text="@string/forgot_your_password"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<Button
android:id="@+id/login_btn"
android:layout_below="@+id/forgot_pass"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:textSize="14sp"
android:textColor="@drawable/login_text_selector"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sign_in"
android:background="@drawable/button_bg"/>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="18dp"
android:layout_marginBottom="20dp"
android:layout_below="@+id/relativeHeader">
<RelativeLayout
android:id="@+id/relativeLayout3"
android:layout_width="match_parent"
android:visibility="invisible"
android:layout_height="wrap_content">
<TextView
android:id="@+id/username_reg_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/username"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/username_reg_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="18dp"
app:hintEnabled="false"
android:layout_below="@+id/username_reg_text"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/username_reg_editText"
android:textColor="@android:color/white"
android:inputType="text"
android:textColorHint="@android:color/white"
android:hint="@string/edittext_hint_username"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/email_reg_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/username_reg_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/email"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/email_reg_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="18dp"
app:hintEnabled="false"
android:layout_below="@+id/email_reg_text"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/email_reg_editText"
android:textColor="@android:color/white"
android:inputType="text"
android:textColorHint="@android:color/white"
android:hint="@string/edittext_hint_email"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/phone_reg_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/email_reg_input_text"
android:textColor="@android:color/white"
android:textSize="16sp"
android:text="@string/phone"/>
<LinearLayout
android:id="@+id/phone_reg_input_text_layout"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/phone_reg_text"
android:gravity="center_vertical">
<com.hbb20.CountryCodePicker
android:id="@+id/ccp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:ccp_textSize="14sp"
app:ccp_contentColor="@android:color/white"
app:ccp_countryPreference="us,ng"/>
<android.support.design.widget.TextInputLayout
android:id="@+id/phone_reg_input_text"
app:hintEnabled="false"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/phone_reg_editText"
android:textColor="@android:color/white"
android:inputType="text"
android:background="@android:color/transparent"
android:textColorHint="@android:color/white"
android:hint="@string/edittext_hint_phone"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<View
android:id="@+id/bottom_border"
android:layout_marginBottom="18dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_below="@+id/phone_reg_input_text_layout"
android:background="@android:color/white"
android:layout_height="1.5dp"
android:layout_width="fill_parent"/>
<TextView
android:id="@+id/pass_reg_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/bottom_border"
android:textColor="@android:color/white"
android:textSize="16sp"
android:text="@string/password"/>
<android.support.design.widget.TextInputLayout
android:id="@+id/pass_reg_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="10dp"
app:hintEnabled="false"
app:passwordToggleEnabled="true"
app:passwordToggleTint="@android:color/white"
android:layout_below="@+id/pass_reg_text"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/pass_reg_editText"
android:textColor="@android:color/white"
android:inputType="textPassword"
android:textColorHint="@android:color/white"
android:hint="@string/edittext_hint_pass"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/register_btn"
android:layout_below="@+id/pass_reg_input_text"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:textSize="14sp"
android:textColor="@drawable/login_text_selector"
android:textAllCaps="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/register"
android:background="@drawable/button_bg"/>
</RelativeLayout>
</ScrollView>
<RelativeLayout
android:id="@+id/relativeLayout4"
android:layout_marginTop="10dp"
android:layout_below="@+id/relativeHeader"
android:visibility="invisible"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/email_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/email"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/retrieve_email_input_text"
app:hintEnabled="false"
android:layout_marginTop="8dp"
android:padding="12dp"
app:passwordToggleTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/retrieve_email_editText"
android:textColor="@android:color/white"
android:textColorHint="@android:color/white"
android:inputType="text"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/retrieve_pass_btn"
android:layout_below="@+id/retrieve_email_input_text"
android:layout_centerHorizontal="true"
android:layout_margin="16dp"
android:textSize="14sp"
android:textColor="@drawable/login_text_selector"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/send"
android:background="@drawable/button_bg"/>
</RelativeLayout>
</RelativeLayout>
<Button
android:id="@+id/back_btn"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="30dp"
android:layout_marginLeft="16dp"
android:visibility="invisible"
android:layout_gravity="top|start"
android:background="@drawable/ic_arrow_back_black_24dp"
android:layout_marginStart="16dp" />
</RelativeLayout>
LoginActivity.java
signInBtn = findViewById(R.id.signin_btn);
signInBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
relativeLayout1.setVisibility(View.INVISIBLE);
relativeLayout2.setVisibility(View.VISIBLE);
backBtn.setVisibility(View.VISIBLE);
}
});
android xml
I have been coding for android for a little while now but recently i encountered an issue that is driving me crazy. I have some child items inside relativeLayout
that i want to assign some click events. However, these buttons are not responding to click events and i don't get any error. I have surfed the net for solution but haven't found any. Please help.
LoginActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LoginActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/bg_image"/>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.65"
android:background="@android:color/black"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/relativeHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:alpha="0.8"
android:layout_gravity="center_horizontal|top">
<ImageView
android:id="@+id/img_logo"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="30dp"
android:layout_centerHorizontal="true"
android:src="@drawable/card"/>
<TextView
android:id="@+id/meet_me_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/img_logo"
android:layout_centerHorizontal="true"
android:text="@string/text"
android:textColor="@android:color/white"
android:textSize="35sp"
android:textStyle="bold"
app:fontFamily="@font/dancing_script_bold" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/email_signup_btn"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:textSize="14sp"
android:textColor="@drawable/login_text_selector"
android:textAllCaps="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sign_up_with_email"
android:background="@drawable/button_bg"/>
<Button
android:id="@+id/signin_btn"
android:layout_below="@+id/email_signup_btn"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:textColor="@drawable/login_text_selector"
android:layout_marginBottom="20dp"
android:textSize="14sp"
android:textAllCaps="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sign_in"
android:background="@drawable/button_bg2"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout2"
android:visibility="invisible"
android:layout_marginTop="20dp"
android:layout_below="@+id/relativeHeader"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/username_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/username"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/username_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="26dp"
android:layout_below="@+id/username_text"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/username_editText"
android:textColor="@android:color/white"
android:inputType="text"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/password_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/username_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/password"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/password_input_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="10dp"
app:passwordToggleTint="@android:color/white"
android:layout_below="@+id/password_text"
app:passwordToggleEnabled="true">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/password_editText"
android:inputType="textPassword"
android:textColor="@android:color/white"
app:backgroundTint="@android:color/white"
android:textCursorDrawable="@drawable/edit_text_cursor"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/forgot_pass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/password_input_text"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="10dp"
android:text="@string/forgot_your_password"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<Button
android:id="@+id/login_btn"
android:layout_below="@+id/forgot_pass"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:textSize="14sp"
android:textColor="@drawable/login_text_selector"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sign_in"
android:background="@drawable/button_bg"/>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="18dp"
android:layout_marginBottom="20dp"
android:layout_below="@+id/relativeHeader">
<RelativeLayout
android:id="@+id/relativeLayout3"
android:layout_width="match_parent"
android:visibility="invisible"
android:layout_height="wrap_content">
<TextView
android:id="@+id/username_reg_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/username"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/username_reg_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="18dp"
app:hintEnabled="false"
android:layout_below="@+id/username_reg_text"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/username_reg_editText"
android:textColor="@android:color/white"
android:inputType="text"
android:textColorHint="@android:color/white"
android:hint="@string/edittext_hint_username"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/email_reg_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/username_reg_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/email"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/email_reg_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="18dp"
app:hintEnabled="false"
android:layout_below="@+id/email_reg_text"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/email_reg_editText"
android:textColor="@android:color/white"
android:inputType="text"
android:textColorHint="@android:color/white"
android:hint="@string/edittext_hint_email"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/phone_reg_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/email_reg_input_text"
android:textColor="@android:color/white"
android:textSize="16sp"
android:text="@string/phone"/>
<LinearLayout
android:id="@+id/phone_reg_input_text_layout"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/phone_reg_text"
android:gravity="center_vertical">
<com.hbb20.CountryCodePicker
android:id="@+id/ccp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:ccp_textSize="14sp"
app:ccp_contentColor="@android:color/white"
app:ccp_countryPreference="us,ng"/>
<android.support.design.widget.TextInputLayout
android:id="@+id/phone_reg_input_text"
app:hintEnabled="false"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/phone_reg_editText"
android:textColor="@android:color/white"
android:inputType="text"
android:background="@android:color/transparent"
android:textColorHint="@android:color/white"
android:hint="@string/edittext_hint_phone"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<View
android:id="@+id/bottom_border"
android:layout_marginBottom="18dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_below="@+id/phone_reg_input_text_layout"
android:background="@android:color/white"
android:layout_height="1.5dp"
android:layout_width="fill_parent"/>
<TextView
android:id="@+id/pass_reg_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/bottom_border"
android:textColor="@android:color/white"
android:textSize="16sp"
android:text="@string/password"/>
<android.support.design.widget.TextInputLayout
android:id="@+id/pass_reg_input_text"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="10dp"
app:hintEnabled="false"
app:passwordToggleEnabled="true"
app:passwordToggleTint="@android:color/white"
android:layout_below="@+id/pass_reg_text"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/pass_reg_editText"
android:textColor="@android:color/white"
android:inputType="textPassword"
android:textColorHint="@android:color/white"
android:hint="@string/edittext_hint_pass"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/register_btn"
android:layout_below="@+id/pass_reg_input_text"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:textSize="14sp"
android:textColor="@drawable/login_text_selector"
android:textAllCaps="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/register"
android:background="@drawable/button_bg"/>
</RelativeLayout>
</ScrollView>
<RelativeLayout
android:id="@+id/relativeLayout4"
android:layout_marginTop="10dp"
android:layout_below="@+id/relativeHeader"
android:visibility="invisible"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/email_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/email"
android:textColor="@android:color/white"
android:textSize="16sp"
app:fontFamily="@font/montaga" />
<android.support.design.widget.TextInputLayout
android:id="@+id/retrieve_email_input_text"
app:hintEnabled="false"
android:layout_marginTop="8dp"
android:padding="12dp"
app:passwordToggleTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/retrieve_email_editText"
android:textColor="@android:color/white"
android:textColorHint="@android:color/white"
android:inputType="text"
android:textCursorDrawable="@drawable/edit_text_cursor"
app:backgroundTint="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/retrieve_pass_btn"
android:layout_below="@+id/retrieve_email_input_text"
android:layout_centerHorizontal="true"
android:layout_margin="16dp"
android:textSize="14sp"
android:textColor="@drawable/login_text_selector"
android:textAllCaps="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/send"
android:background="@drawable/button_bg"/>
</RelativeLayout>
</RelativeLayout>
<Button
android:id="@+id/back_btn"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="30dp"
android:layout_marginLeft="16dp"
android:visibility="invisible"
android:layout_gravity="top|start"
android:background="@drawable/ic_arrow_back_black_24dp"
android:layout_marginStart="16dp" />
</RelativeLayout>
LoginActivity.java
signInBtn = findViewById(R.id.signin_btn);
signInBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
relativeLayout1.setVisibility(View.INVISIBLE);
relativeLayout2.setVisibility(View.VISIBLE);
backBtn.setVisibility(View.VISIBLE);
}
});
android xml
android xml
edited Jan 20 at 4:13
Halcn
327
327
asked Jan 20 at 3:53
bnotion softwarebnotion software
11
11
Not sure that this is your problem, but you should be using "gone" rather than "invisible", in your layout and also in your code.
– lionscribe
Jan 20 at 5:44
add a comment |
Not sure that this is your problem, but you should be using "gone" rather than "invisible", in your layout and also in your code.
– lionscribe
Jan 20 at 5:44
Not sure that this is your problem, but you should be using "gone" rather than "invisible", in your layout and also in your code.
– lionscribe
Jan 20 at 5:44
Not sure that this is your problem, but you should be using "gone" rather than "invisible", in your layout and also in your code.
– lionscribe
Jan 20 at 5:44
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54273435%2fbutton-inside-relative-layout-not-responding-to-clicks%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54273435%2fbutton-inside-relative-layout-not-responding-to-clicks%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Not sure that this is your problem, but you should be using "gone" rather than "invisible", in your layout and also in your code.
– lionscribe
Jan 20 at 5:44