Changing input in an EditText updates the wrong EditText inside ScrollView - android

I am going through a peculiar problem. I have multiple EditText inside a RelativeLayout which is ultimately inside a ScrollView. My problem is that whenever I edit the second(or third and so on) EditText, it loses focus to the first EditText inside the ScrollView and this first EditText gets the keyboard input.
Here goes the xml layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/parentLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/particularsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="50dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp">
<TextView
android:id="#+id/particularsTextView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PARTICULARS"
android:textColor="#android:color/darker_gray"
android:textStyle="bold"
/>
<View
android:id="#+id/bar1"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray"
android:layout_below="#+id/particularsTextView"
/>
<RelativeLayout
android:id="#+id/particularsParentRelativeLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/bar1"
android:layout_marginTop="10dp"
>
<EditText
android:id="#+id/nameEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="15dp"
android:layout_alignLeft="#+id/confirmPasswordEditText"
/>
<TextView
android:id="#+id/nameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NAME"
android:textColor="#android:color/darker_gray"
android:textStyle="bold"
android:layout_alignBottom="#+id/nameEditText"
android:layout_marginBottom="15dp"
android:textSize="12sp"
/>
<TextView
android:id="#+id/passwordTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PASSWORD"
android:textColor="#android:color/darker_gray"
android:textStyle="bold"
android:layout_alignBottom="#+id/passwordEditText"
android:layout_marginBottom="15dp"
android:textSize="12sp"
/>
<EditText
android:id="#+id/passwordEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/nameEditText"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/passwordTextView"
android:layout_alignParentRight="true"
android:nextFocusUp="#+id/passwordEditText"
android:layout_alignLeft="#+id/confirmPasswordEditText"
/>
<TextView
android:id="#+id/confirmPasswordTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CONFIRM PASSWORD"
android:textColor="#android:color/darker_gray"
android:textStyle="bold"
android:layout_alignBottom="#+id/confirmPasswordEditText"
android:layout_marginBottom="15dp"
android:textSize="12sp"
/>
<EditText
android:id="#+id/confirmPasswordEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/passwordEditText"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/confirmPasswordTextView"
android:layout_alignParentRight="true"
android:layout_marginLeft="5dp"
/>
<TextView
android:id="#+id/birthdayTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BIRTHDAY"
android:textColor="#android:color/darker_gray"
android:textStyle="bold"
android:layout_alignBottom="#+id/birthdayEditText"
android:layout_marginBottom="15dp"
android:textSize="12sp"
/>
<EditText
android:id="#+id/birthdayEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/confirmPasswordEditText"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/birthdayTextView"
android:layout_alignParentRight="true"
android:layout_alignLeft="#+id/confirmPasswordEditText"
/>
<TextView
android:id="#+id/genderTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="GENDER"
android:textColor="#android:color/darker_gray"
android:textStyle="bold"
android:layout_marginTop="18dp"
android:layout_below="#+id/birthdayTextView"
android:textSize="12sp"
/>
<TextView
android:id="#+id/contactDetailsTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/genderTextView"
android:text="CONTACT DETAILS"
android:textColor="#android:color/darker_gray"
android:textStyle="bold"
android:layout_marginTop="50dp"
/>
<View
android:id="#+id/bar2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray"
android:layout_below="#+id/contactDetailsTextView"
/>
<TextView
android:id="#+id/contactNoTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/contactNoEditText"
android:layout_marginBottom="15dp"
android:text="CONTACT NO."
android:textSize="12sp"
android:textColor="#android:color/darker_gray"
android:textStyle="bold"
/>
<EditText
android:id="#+id/contactNoEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/bar2"
android:layout_marginTop="15dp"
android:layout_alignParentRight="true"
android:layout_alignLeft="#+id/confirmPasswordEditText"
/>
<TextView
android:id="#+id/emailAddressTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="EMAIL AD."
android:textColor="#android:color/darker_gray"
android:textStyle="bold"
android:layout_alignBottom="#+id/emailAddressEditText"
android:layout_marginBottom="15dp"
android:textSize="12sp"
/>
<EditText
android:id="#+id/emailAddressEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/contactNoEditText"
android:layout_marginTop="10dp"
android:layout_alignParentRight="true"
android:layout_alignLeft="#+id/confirmPasswordEditText"
/>
<EditText
android:id="#+id/emailAddressEditText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/emailAddressTextView"
android:layout_marginTop="10dp"
android:layout_alignParentRight="true"
android:layout_alignLeft="#+id/confirmPasswordEditText"
/>
<TextView
android:id="#+id/countryTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="COUNTRY"
android:textColor="#android:color/darker_gray"
android:textStyle="bold"
android:layout_below="#+id/emailAddressEditText2"
android:layout_marginTop="18dp"
android:textSize="12sp"
/>
<CheckBox
android:id="#+id/termsCheckbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/countryTextView" />
<TextView
android:id="#+id/termsTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/termsCheckbox"
android:layout_alignBottom="#+id/termsCheckbox"
android:text="I AGREE TO THE TERMS AND CONDITIONS STATED"
android:textColor="#android:color/darker_gray"
android:layout_alignBaseline="#+id/termsCheckbox"
/>
<Button
android:id="#+id/signupButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/termsTextView"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#drawable/signup"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp"
/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
How to resolve this issue ?
EDIT:
I have attached a screenshot of my problem. I have entered "h" in the passwordEditText but nameEditText gets the value.

mTabHost.addOnAttachStateChangeListener(new OnAttachStateChangeListener() {
#Override
public void onViewDetachedFromWindow(View v) {}
#Override
public void onViewAttachedToWindow(View v) {
mTabHost.getViewTreeObserver().removeOnTouchModeChangeListener(mTabHost);
}
});
Add this code in MainActivity.Java #setTabs() function after
mTabHost.setup(this, getSupportFragmentManager(), android.R.id.tabcontent);
this line.
Best of luck.

You can set focus to desired edit text after you make the change: ex.
myEditText3.setFocusableInTouchMode(true);
myEditText3.requestFocus();

It's Working in my device.
I don't know why it's not working in yours, I think in java code, there may be some error.
But you can try,
<RelativeLayout
android:id="#+id/parentLayout"
android:layout_width="match_parent"
android:focusableInTouchMode="true"
android:layout_height="match_parent" >
add 3rd line to your "parentLayout"

Related

Android studio showing out of memory and asking to increase the size. It is getting when I open one of the xml resource file

I used 20 spinners and 40 textviews for displaying the name poster. When I edit this xml resource file Android Studio showing popup is Out of memory error
Here is the popup
I incresed the xmx size to 2048.
Eventhogh it showing same error when I open that xml file. here I put the xml code.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/adViewContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.85">
<RelativeLayout
android:id="#+id/relNameLayout"
android:layout_width="match_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/spinner"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="18dp"
android:layout_marginStart="18dp"
android:layout_marginTop="15dp"
android:gravity="right"
android:textColor="#ff0000"
android:visibility="invisible" />
<Spinner
android:id="#+id/spinner2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/spinner"
android:layout_marginLeft="25dp"
android:layout_marginStart="25dp"
android:layout_toRightOf="#+id/spinner"
android:visibility="invisible" />
<TextView
android:id="#+id/txtSpinner2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/spinner3"
android:layout_alignTop="#+id/spinner"
android:layout_marginLeft="25dp"
android:layout_marginStart="25dp"
android:layout_toRightOf="#+id/spinner"
android:gravity="left"
android:textColor="#0287FC"
android:visibility="invisible" />
<TextView
android:id="#+id/spinner3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/spinner"
android:layout_alignLeft="#+id/spinner"
android:layout_alignRight="#+id/spinner"
android:layout_alignStart="#+id/spinner"
android:layout_below="#+id/spinner"
android:layout_marginTop="6dp"
android:gravity="right"
android:textColor="#ff0000"
android:visibility="invisible" />
<Spinner
android:id="#+id/spinner4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner2"
android:layout_alignStart="#+id/spinner2"
android:layout_alignTop="#+id/spinner3"
android:visibility="invisible" />
<TextView
android:id="#+id/txtSpinner4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/spinner5"
android:layout_alignLeft="#+id/spinner4"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignStart="#+id/spinner4"
android:layout_alignTop="#+id/spinner4"
android:gravity="left"
android:textColor="#0287FC"
android:visibility="invisible" />
<TextView
android:id="#+id/spinner5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/spinner3"
android:layout_alignLeft="#+id/spinner3"
android:layout_alignRight="#+id/spinner3"
android:layout_alignStart="#+id/spinner3"
android:layout_below="#+id/spinner3"
android:layout_marginTop="6dp"
android:gravity="right"
android:textColor="#ff0000"
android:visibility="invisible" />
<Spinner
android:id="#+id/spinner6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner4"
android:layout_alignStart="#+id/spinner4"
android:layout_alignTop="#+id/spinner5"
android:visibility="invisible" />
<TextView
android:id="#+id/txtSpinner6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/spinner7"
android:layout_alignLeft="#+id/spinner6"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignStart="#+id/spinner6"
android:layout_alignTop="#+id/spinner6"
android:gravity="left"
android:textColor="#0287FC"
android:visibility="invisible" />
<TextView
android:id="#+id/spinner7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/spinner5"
android:layout_alignLeft="#+id/spinner5"
android:layout_alignRight="#+id/spinner5"
android:layout_alignStart="#+id/spinner5"
android:layout_below="#+id/spinner5"
android:layout_marginTop="6dp"
android:gravity="right"
android:textColor="#ff0000"
android:visibility="invisible" />
<Spinner
android:id="#+id/spinner8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner6"
android:layout_alignStart="#+id/spinner6"
android:layout_alignTop="#+id/spinner7"
android:visibility="invisible" />
<TextView
android:id="#+id/txtSpinner8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/spinner9"
android:layout_alignLeft="#+id/spinner6"
android:layout_alignStart="#+id/spinner6"
android:layout_alignTop="#+id/spinner7"
android:gravity="left"
android:textColor="#0287FC"
android:visibility="invisible" />
<TextView
android:id="#+id/spinner9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/spinner7"
android:layout_alignLeft="#+id/spinner7"
android:layout_alignRight="#+id/spinner7"
android:layout_alignStart="#+id/spinner7"
android:layout_below="#+id/spinner7"
android:layout_marginTop="6dp"
android:gravity="right"
android:textColor="#ff0000"
android:visibility="invisible" />
<Spinner
android:id="#+id/spinner10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner8"
android:layout_alignStart="#+id/spinner8"
android:layout_alignTop="#+id/spinner9"
android:visibility="invisible" />
<TextView
android:id="#+id/txtSpinner10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/spinner11"
android:layout_alignLeft="#+id/spinner8"
android:layout_alignStart="#+id/spinner8"
android:layout_alignTop="#+id/spinner9"
android:gravity="left"
android:textColor="#0287FC"
android:visibility="invisible" />
<TextView
android:id="#+id/spinner11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/spinner9"
android:layout_alignLeft="#+id/spinner9"
android:layout_alignRight="#+id/spinner9"
android:layout_alignStart="#+id/spinner9"
android:layout_below="#+id/spinner9"
android:layout_marginTop="6dp"
android:gravity="right"
android:textColor="#ff0000"
android:visibility="invisible" />
<Spinner
android:id="#+id/spinner12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner10"
android:layout_alignStart="#+id/spinner10"
android:layout_alignTop="#+id/spinner11"
android:visibility="invisible" />
<TextView
android:id="#+id/txtSpinner12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/spinner13"
android:layout_alignLeft="#+id/spinner12"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignStart="#+id/spinner12"
android:layout_alignTop="#+id/spinner12"
android:gravity="left"
android:textColor="#0287FC"
android:visibility="invisible" />
<TextView
android:id="#+id/spinner13"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/spinner11"
android:layout_alignLeft="#+id/spinner11"
android:layout_alignRight="#+id/spinner11"
android:layout_alignStart="#+id/spinner11"
android:layout_below="#+id/spinner11"
android:layout_marginTop="6dp"
android:gravity="right"
android:textColor="#ff0000"
android:visibility="invisible" />
<Spinner
android:id="#+id/spinner14"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner12"
android:layout_alignStart="#+id/spinner12"
android:layout_alignTop="#+id/spinner13"
android:visibility="invisible" />
<TextView
android:id="#+id/txtSpinner14"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/spinner15"
android:layout_alignLeft="#+id/spinner12"
android:layout_alignStart="#+id/spinner12"
android:layout_alignTop="#+id/spinner13"
android:gravity="left"
android:textColor="#0287FC"
android:visibility="invisible" />
<TextView
android:id="#+id/spinner15"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/spinner13"
android:layout_alignLeft="#+id/spinner13"
android:layout_alignRight="#+id/spinner13"
android:layout_alignStart="#+id/spinner13"
android:layout_below="#+id/spinner13"
android:layout_marginTop="6dp"
android:gravity="right"
android:textColor="#ff0000"
android:visibility="invisible" />
<Spinner
android:id="#+id/spinner16"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner14"
android:layout_alignStart="#+id/spinner14"
android:layout_alignTop="#+id/spinner15"
android:visibility="invisible" />
<TextView
android:id="#+id/txtSpinner16"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner14"
android:layout_alignStart="#+id/spinner14"
android:layout_alignTop="#+id/spinner15"
android:textColor="#0287FC"
android:visibility="invisible" />
<TextView
android:id="#+id/spinner17"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/spinner15"
android:layout_alignLeft="#+id/spinner15"
android:layout_alignRight="#+id/spinner15"
android:layout_alignStart="#+id/spinner15"
android:layout_below="#+id/spinner15"
android:layout_marginTop="6dp"
android:gravity="right"
android:textColor="#ff0000"
android:visibility="invisible" />
<Spinner
android:id="#+id/spinner18"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner16"
android:layout_alignStart="#+id/spinner16"
android:layout_alignTop="#+id/spinner17"
android:layout_below="#+id/spinner16"
android:visibility="invisible" />
<TextView
android:id="#+id/txtSpinner18"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner16"
android:layout_alignStart="#+id/spinner16"
android:layout_alignTop="#+id/spinner17"
android:layout_below="#+id/txtSpinner16"
android:gravity="left"
android:textColor="#0287FC"
android:visibility="invisible" />
<TextView
android:id="#+id/spinner19"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/spinner17"
android:layout_alignLeft="#+id/spinner17"
android:layout_alignRight="#+id/spinner17"
android:layout_alignStart="#+id/spinner17"
android:layout_below="#+id/spinner17"
android:layout_marginTop="6dp"
android:gravity="right"
android:textColor="#ff0000"
android:visibility="invisible" />
<Spinner
android:id="#+id/spinner20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner18"
android:layout_alignStart="#+id/spinner18"
android:layout_alignTop="#+id/spinner19"
android:layout_below="#+id/spinner18"
android:visibility="invisible" />
<TextView
android:id="#+id/txtSpinner20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner18"
android:layout_alignStart="#+id/spinner18"
android:layout_alignTop="#+id/spinner19"
android:layout_below="#+id/txtSpinner18"
android:gravity="left"
android:textColor="#0287FC"
android:visibility="invisible" />
<TextView
android:id="#+id/spinner21"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/spinner19"
android:layout_alignLeft="#+id/spinner19"
android:layout_alignRight="#+id/spinner19"
android:layout_alignStart="#+id/spinner19"
android:layout_below="#+id/spinner19"
android:layout_marginTop="6dp"
android:gravity="right"
android:textColor="#ff0000"
android:visibility="invisible" />
<Spinner
android:id="#+id/spinner22"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner20"
android:layout_alignStart="#+id/spinner20"
android:layout_alignTop="#+id/spinner21"
android:layout_below="#+id/spinner20"
android:visibility="invisible" />
<TextView
android:id="#+id/txtSpinner22"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner20"
android:layout_alignStart="#+id/spinner20"
android:layout_alignTop="#+id/spinner21"
android:layout_below="#+id/txtSpinner20"
android:gravity="left"
android:textColor="#0287FC"
android:visibility="invisible" />
<TextView
android:id="#+id/spinner23"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/spinner21"
android:layout_alignLeft="#+id/spinner21"
android:layout_alignRight="#+id/spinner21"
android:layout_alignStart="#+id/spinner21"
android:layout_below="#+id/spinner21"
android:layout_marginTop="6dp"
android:gravity="right"
android:textColor="#ff0000"
android:visibility="invisible" />
<Spinner
android:id="#+id/spinner24"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner22"
android:layout_alignStart="#+id/spinner22"
android:layout_alignTop="#+id/spinner23"
android:layout_below="#+id/spinner22"
android:visibility="invisible" />
<TextView
android:id="#+id/txtSpinner24"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner22"
android:layout_alignStart="#+id/spinner22"
android:layout_alignTop="#+id/spinner23"
android:layout_below="#+id/txtSpinner22"
android:gravity="left"
android:textColor="#0287FC"
android:visibility="invisible" />
<TextView
android:id="#+id/spinner25"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/spinner23"
android:layout_alignLeft="#+id/spinner23"
android:layout_alignRight="#+id/spinner23"
android:layout_alignStart="#+id/spinner23"
android:layout_below="#+id/spinner23"
android:layout_marginTop="6dp"
android:gravity="right"
android:textColor="#ff0000"
android:visibility="invisible" />
<Spinner
android:id="#+id/spinner26"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner24"
android:layout_alignStart="#+id/spinner24"
android:layout_alignTop="#+id/spinner25"
android:layout_below="#+id/spinner24"
android:visibility="invisible" />
<TextView
android:id="#+id/txtSpinner26"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner24"
android:layout_alignStart="#+id/spinner24"
android:layout_alignTop="#+id/spinner25"
android:layout_below="#+id/txtSpinner24"
android:gravity="left"
android:textColor="#0287FC"
android:visibility="invisible" />
<TextView
android:id="#+id/spinner27"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/spinner25"
android:layout_alignLeft="#+id/spinner25"
android:layout_alignRight="#+id/spinner25"
android:layout_alignStart="#+id/spinner25"
android:layout_below="#+id/spinner25"
android:layout_marginTop="6dp"
android:gravity="right"
android:textColor="#ff0000"
android:visibility="invisible" />
<Spinner
android:id="#+id/spinner28"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner26"
android:layout_alignStart="#+id/spinner26"
android:layout_alignTop="#+id/spinner27"
android:layout_below="#+id/spinner26"
android:visibility="invisible" />
<TextView
android:id="#+id/txtSpinner28"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner26"
android:layout_alignStart="#+id/spinner26"
android:layout_alignTop="#+id/spinner27"
android:layout_below="#+id/txtSpinner26"
android:gravity="left"
android:textColor="#0287FC"
android:visibility="invisible" />
<TextView
android:id="#+id/spinner29"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/spinner27"
android:layout_alignLeft="#+id/spinner27"
android:layout_alignRight="#+id/spinner27"
android:layout_alignStart="#+id/spinner27"
android:layout_below="#+id/spinner27"
android:layout_marginTop="6dp"
android:gravity="right"
android:textColor="#ff0000"
android:visibility="invisible" />
<Spinner
android:id="#+id/spinner30"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/spinner28"
android:layout_alignStart="#+id/spinner28"
android:layout_alignTop="#+id/spinner29"
android:layout_below="#+id/spinner28"
android:visibility="invisible" />
.........
..........
.........
</RelativeLayout>
</ScrollView>
I used 20 spinners and 40 textviews layout to display a poster as following shown. Is there any other way to get that please do let me know.
My poster
I was fighting with this problem today for a few hours and ended up trying File -> Invalidate Caches / Restart... and chose the Invalidate/Restart option. Seems to have fixed the Out of Memory error.
Don't know if that will work for you at a later time, but hopefully it helps.

Align Parent Bottom With Below RelativeLayout Android

Good day.I have an set of buttons which should be aligned to the bottom always,but they all also should be below an text,and it goes like this,if text is large,it is going just to push the buttons inside the scrollview,otherwise the buttons should be aligned to the parent bottom.Issue is that i add both of the tags to the linear layout wrapper of the buttons,but as soon as i set visibility of text to gone,the view just pops up and not aligning to parent bottom,here is the actual code,
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/single_product_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/single_product_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="35dp"
android:src="#drawable/img_placeholder" />
<RelativeLayout
android:id="#+id/basket_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_divider"
android:layout_alignEnd="#+id/single_product_divider"
android:layout_alignLeft="#+id/single_product_divider"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/single_product_divider"
android:layout_alignStart="#+id/single_product_divider"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:visibility="gone">
<ImageView
android:id="#+id/basket_success_icon"
android:layout_width="46dp"
android:layout_height="46dp"
android:layout_centerVertical="true"
android:layout_marginLeft="26dp"
android:src="#drawable/success_icon" />
<TextView
android:id="#+id/basket_product_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/basket_success_icon"
android:layout_marginLeft="16dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/basket_success_icon"
android:text="#string/product_added_to_basket_text"
android:textColor="#ffffff"
android:textSize="16sp" />
</RelativeLayout>
<View
android:id="#+id/single_product_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/single_product_image"
android:layout_margin="25dp"
android:background="#D1D3D4">
</View>
<TextView
android:id="#+id/single_product_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_divider"
android:layout_alignStart="#+id/single_product_divider"
android:layout_below="#+id/single_product_divider"
android:text="#string/loading_text"
android:textColor="#231F20" />
<TextView
android:id="#+id/single_product_weight_and_servings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_divider"
android:layout_alignStart="#+id/single_product_divider"
android:layout_below="#+id/single_product_name"
android:layout_marginTop="5dp"
android:text="#string/weight_and_servings_text"
android:textColor="#231F20" />
<TextView
android:id="#+id/single_product_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_weight_and_servings"
android:layout_alignStart="#+id/single_product_weight_and_servings"
android:layout_below="#+id/single_product_weight_and_servings"
android:layout_marginTop="15dp"
android:text="$12.09"
android:textColor="#009444"
android:textSize="17sp"
android:textStyle="bold" />
<RatingBar
android:id="#+id/single_product_rating"
style="#style/Base.Widget.AppCompat.RatingBar.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/single_product_price"
android:layout_alignStart="#+id/single_product_price"
android:layout_below="#+id/single_product_price"
android:layout_marginTop="5dp"
android:numStars="5" />
<TextView
android:id="#+id/single_product_rating_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/single_product_rating"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/single_product_rating"
android:text="10.0/10"
android:textColor="#231F20"
android:textSize="12sp" />
<TextView
android:id="#+id/single_product_review_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/single_product_rating_text"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/single_product_rating_text"
android:text="8 reviews"
android:textColor="#EC2027"
android:textSize="12sp" />
<TextView
android:id="#+id/single_product_stock_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/single_product_review_count"
android:layout_marginRight="10dp"
android:text="In stock"
android:textColor="#939598" />
<View
android:id="#+id/single_product_center_divider"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="#+id/single_product_rating"
android:layout_centerHorizontal="true"></View>
<Spinner
android:id="#+id/single_product_weight_spinner"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/single_product_rating"
android:layout_marginLeft="10dp"
android:layout_marginRight="2dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#+id/single_product_center_divider"
android:background="#drawable/spinner_background"
android:spinnerMode="dropdown"></Spinner>
<Spinner
android:id="#+id/single_product_type_spinner"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_below="#+id/single_product_rating"
android:layout_marginLeft="2dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/single_product_center_divider"
android:background="#drawable/spinner_background"
android:spinnerMode="dropdown"></Spinner>
<TextView
android:id="#+id/single_product_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_type_spinner"
android:layout_margin="16dp"
android:text="This is simply the best tripod for the money you\'ll ever buy,it\'s rock solid and the head alone is worth more then the asking price"
android:textColor="#231F20" />
<RelativeLayout
android:id="#+id/single_product_buttons_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/single_product_description"
android:orientation="vertical">
<Button
android:id="#+id/single_product_add_to_cart_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#F26522"
android:text="#string/add_to_cart_text"
android:textAllCaps="false"
android:textColor="#ffffff" />
<Button
android:id="#+id/single_product_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_add_to_cart_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:drawableRight="#drawable/ic_arrow_down"
android:paddingRight="10dp"
android:text="#string/product_info_text"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_nutritional_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_info_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:drawableRight="#drawable/ic_arrow_down"
android:paddingRight="10dp"
android:text="#string/product_nutritional_text"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_reviews_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/single_product_nutritional_info_button"
android:layout_marginBottom="5dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:drawableRight="#drawable/ic_arrow_down"
android:paddingRight="10dp"
android:text="#string/product_reviews_text"
android:textAllCaps="false"
android:textColor="#231F20" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
Can anyone please give any suggestion?
Edit : The full code of the view,actual buttons are inside RelativeLayout at the bottom of xml files there are 4 of buttons.The wrapper is single_product_buttons_wrapper
Add android:gravity="bottom" to LinearLayout containing buttons. It will work have tested it.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/single_product_description"
android:gravity="bottom"
android:orientation="vertical">
Try this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true">
<TextView
android:id="#+id/single_product_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="This is simply the best tripod for the money you\'ll ever buy,it\'s rock solid and the head alone is worth more then the asking price"
android:textColor="#231F20" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<Button
android:id="#+id/single_product_add_to_cart_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_info_button"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#F26522"
android:text="123"
android:textAllCaps="false"
android:textColor="#ffffff" />
<Button
android:id="#+id/single_product_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_nutritional_info_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:paddingRight="10dp"
android:text="234"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_nutritional_info_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/single_product_reviews_button"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:paddingRight="10dp"
android:text="5555"
android:textAllCaps="false"
android:textColor="#231F20" />
<Button
android:id="#+id/single_product_reviews_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp"
android:background="#E7E8E9"
android:paddingRight="10dp"
android:text="99999"
android:textAllCaps="false"
android:textColor="#231F20" />
</LinearLayout>
</RelativeLayout>

Layout not getting GONE sometimes in android

I have a relative layout with an image and title.Below the relativelayout I have an Editext(used for searching which will display a search result listview based on change of text in the edittext).So once i touch on the EDITExt softkeyboard will appear and the top layout's visibility is set to 'Gone'.It works fine but sometimes the edittext moves up but the top layout is visible like ui frozen and this will disapppear when we enter a keystroke for edittext.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/violetbg"
android:id="#+id/parentt"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/framestepone"
/>
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_toRightOf="#+id/framestepone"
>
<RelativeLayout
android:layout_height="#dimen/titlebarsize"
android:layout_width="match_parent"
android:background="#color/red"
android:layout_alignParentTop="true"
android:id="#+id/topbar"
>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerInParent="true"
style="#style/actionbarphonetextviewstyle"
android:text="#string/steponetitle"
android:id="#+id/steponetitle"
/>
<ImageButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="#drawable/sidemenutest"
android:id="#+id/sidemenu"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:layout_centerVertical="true"
android:background="#null"
/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/initlay"
android:layout_height="wrap_content"
android:layout_below="#+id/topbar"
android:layout_marginTop="3dp"
android:layout_width="match_parent">
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="#+id/layyy"
>
<TextView
android:layout_centerHorizontal="true"
android:id="#+id/steptag"
android:text="#string/steptagg"
android:textStyle="bold"
android:textColor="#color/white"
android:textSize="#dimen/titletextsize"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="30dp"
/>
<TextView
android:layout_centerHorizontal="true"
android:id="#+id/steponetag"
android:text="#string/onetag"
android:textStyle="bold"
android:textColor="#color/white"
android:textSize="#dimen/titletextsize"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="#+id/steptag"
android:layout_marginTop="5dp"
/>
<ImageView
android:id="#+id/steponebg"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="#drawable/stepone"
android:layout_below="#+id/steponetag"
android:layout_centerHorizontal="true"
/>
<TextView
android:layout_centerHorizontal="true"
android:id="#+id/steponetext"
android:text="#string/chooser"
android:textStyle="bold"
android:textColor="#color/white"
android:textSize="#dimen/titletextsize"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="#+id/steponebg"
android:textAllCaps="true"
android:layout_marginTop="20dp"
/>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativebag"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_below="#+id/initlay"
android:layout_marginTop="10dp"
android:focusableInTouchMode="true"
>
<RelativeLayout
android:id="#+id/relativebagforlist"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_centerHorizontal="true"
>
<EditText
android:layout_height="60dp"
android:layout_width="match_parent"
android:hint="Search & Preview Song"
android:id="#+id/searchsong"
android:inputType="textNoSuggestions"
android:textColor="#color/black"
android:textSize="#dimen/text_size_small"
android:background="#drawable/steponetextboxbg"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:singleLine="true"
android:paddingLeft="12dp"
android:imeOptions="actionDone"
android:paddingRight="8dp"
/>
<RelativeLayout
android:layout_height="60dp"
android:layout_width="match_parent"
android:layout_centerInParent="true"
android:background="#drawable/steponetextboxbg"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:visibility="gone"
android:id="#+id/parntrecrd"
>
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:id="#+id/lay"
android:layout_marginLeft="10dp"
>
<ImageButton
android:id="#+id/playbtns"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="#drawable/play"
android:background="#null"
android:layout_centerVertical="true"
android:paddingLeft="5dp"
/>
<ImageButton
android:id="#+id/pausebtns"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="#drawable/pause"
android:background="#null"
android:layout_centerVertical="true"
android:paddingLeft="5dp"
android:visibility="gone"
/>
</RelativeLayout>
<TextView
android:id="#+id/txtsearche"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_toRightOf="#+id/lay"
android:background="#color/white"
android:clickable="true"
android:gravity="center_vertical"
android:hint="search song"
android:inputType="none"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#color/black"
android:textSize="#dimen/text_size_small" />
</RelativeLayout>
</RelativeLayout>
<ImageButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="#drawable/question"
android:background="#null"
android:layout_below="#+id/relativebagforlist"
android:layout_alignRight="#+id/relativebagforlist"
android:layout_marginTop="5dp"
android:id="#+id/btnhelp"
android:layout_marginRight="10dp"
/>
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignTop="#+id/btnhelp"
android:layout_alignBottom="#+id/btnhelp"
android:layout_toLeftOf="#+id/btnhelp"
android:layout_marginRight="5dp"
android:layout_below="#+id/relativebagforlist"
>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="#+id/hlptxt"
android:layout_marginTop="5dp"
android:text="#string/help"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
<Button
android:layout_height="#dimen/btnheights"
android:layout_width="match_parent"
android:text="#string/readybutton"
android:id="#+id/btnready"
android:textColor="#color/white"
android:background="#drawable/buttonbackground"
style="#style/actionbarphonetextviewstyle"
android:layout_marginTop="10dp"
android:layout_alignParentBottom="true"
android:textAlignment="center"
/>
<ListView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="#+id/lstsongs"
android:background="#color/white"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:visibility="gone"
android:clickable="true"
android:layout_marginTop="10dp"
android:layout_below="#+id/relativebagforlist"
/>
<TextView
android:layout_height="60dp"
android:layout_width="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:visibility="gone"
android:layout_below="#+id/relativebagforlist"
android:background="#color/white"
android:text="#string/nomatch"
android:id="#+id/nomatchtext"
android:textColor="#color/black"
android:paddingLeft="10dp"
android:gravity="center_vertical"
/>
</RelativeLayout>
<!-- ******************************************** -->
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="#+id/progrest"
android:visibility="gone"
android:layout_centerInParent="true"
/>
</RelativeLayout>
</RelativeLayout>
and my code after clicking the textview which will invoke the softkeyboard making the edittext visible and top layout gone is as follows
txtsearch.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
temptext=(txtsearch.getText().toString());
help.setVisibility(View.GONE);
helptext.setVisibility(View.GONE);
txtrecord.setVisibility(View.GONE);
searchsong.setVisibility(View.VISIBLE);
steptag.setVisibility(View.GONE);
steponetag.setVisibility(View.GONE);
steponebg.setVisibility(View.GONE);
steponetext.setVisibility(View.GONE);
lay.setVisibility(View.GONE);
searchsong.requestFocus();
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.showSoftInput(searchsong, InputMethodManager.SHOW_FORCED);
searchsong.setText(temptext);
if(myMap.size()==0){
new Getsongs().execute();
}
}
});
I solved it by removing android:windowSoftInputMode="adjustResize|stateHidden"
from my manifest

Android not finding View IDs

So I have a layout that I'm working on, and just to make sure everything is looking OK on an actual phone I'm doing a test run before I move on with the other labels. But, the problem is, Eclipse can only find one id contactName. The other id's all have an error saying that Android can't find them. My XML File is below:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/contactPicture"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="31dp"
android:layout_marginTop="34dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/nameLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/contactPicture"
android:layout_marginLeft="30dp"
android:layout_toRightOf="#+id/contactPicture"
android:text="#string/name"
android:textSize="16sp"/>
<TextView
android:id="#+id/contactName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/nameLabel"
android:layout_below="#+id/nameLabel"
android:text="TextView"
android:textSize="20sp" />
<TextView
android:id="#+id/companyLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/companyName"
android:layout_alignLeft="#+id/companyName"
android:text="#string/company"
android:textSize="16sp" />
<TextView
android:id="#+id/companyName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/contactPicture"
android:layout_alignLeft="#+id/contactName"
android:text="TextView"
android:textSize="20sp" />
<TextView
android:id="#+id/phoneLabel"
android:text="Phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/contactPicture"
android:layout_alignLeft="#+id/contactPicture"
android:layout_marginTop="30sp"
android:textSize="16sp"/>
<TextView
android:id="#+id/workNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Work Num"
android:textSize="20sp"
android:layout_below="#+id/phoneLabel"
android:layout_alignLeft="#+id/phoneLabel" />
<TextView
android:id="#+id/homeNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Home Num"
android:textSize="20sp"
android:layout_below="#+id/workNum"
android:layout_alignLeft="#+id/workNum" />
<TextView
android:id="#+id/mobileNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile Num"
android:textSize="20sp"
android:layout_below="#+id/homeNum"
android:layout_alignLeft="#+id/homeNum" />
<TextView
android:id="#+id/workLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Work"
android:textSize="20sp"
android:layout_toRightOf="#+id/workNum"
android:layout_alignTop="#+id/workNum"
android:layout_marginLeft="120sp" />
<TextView
android:id="#+id/homeLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Home"
android:textSize="20sp"
android:layout_below="#+id/workLabel"
android:layout_alignLeft="#+id/workLabel" />
<TextView
android:id="#+id/mobileLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile"
android:textSize="20sp"
android:layout_below="#+id/homeLabel"
android:layout_alignLeft="#+id/workLabel" />
</RelativeLayout>
</ScrollView>

Create a listview with sides like older email android app

I want to create a listview like older gmail app. See the screenshot:
I tried putting an empty view like this:
<TextView
android:id="#+id/color_highlight"
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#ff0000"
android:minHeight="48dp" />
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#id/color_highlight"
android:text="Mudit Agarwal"
android:textStyle="bold"
android:textColor="#242424"
android:textIsSelectable="false"
android:textSize="22sp" />
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#id/name"
android:layout_below="#id/name"
android:text="9933445566"
android:textColor="#777777"
android:textIsSelectable="false"
android:layout_marginBottom="10dp"
android:textSize="15sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:padding="3dp"
android:src="#drawable/contact" />
but this is not taking full height of the view. Please suggest.
What I changed is
android:layout_alignBottom="#+id/number"
to your color_highlight TextView. and instead of margin, I put padding like below in number TextView.
android:paddingBottom="20dp"
just put following layout code.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/color_highlight"
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_alignBottom="#+id/number"
android:background="#ff0000"
android:minHeight="48dp" />
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#id/color_highlight"
android:text="Mudit Agarwal"
android:textColor="#242424"
android:textIsSelectable="false"
android:textSize="22sp"
android:textStyle="bold" />
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#id/name"
android:layout_below="#id/name"
android:paddingBottom="20dp"
android:text="9933445566"
android:textColor="#777777"
android:textIsSelectable="false"
android:textSize="15sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:padding="3dp"
android:src="#drawable/contact" />
</RelativeLayout>
I'm not sure but you can try putting android:layout_height="0dip" instead of android:layout_height="match_parent".

Categories

Resources