Layout not getting GONE sometimes in android - 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

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>

Scrollview not working properly.Screen doesn't scroll when input keyboards up

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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="#layout/toolbar"/>
<ScrollView
android:id="#+id/scroll"
android:layout_width="wrap_content"
android:layout_below="#+id/toolbar"
android:layout_height="wrap_content"
android:layout_above="#+id/makeOffer"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="#+id/firstcard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/padding_8dp"
android:layout_marginLeft="#dimen/padding_8dp"
android:layout_marginRight="#dimen/padding_8dp"
android:layout_marginTop="#dimen/padding_8dp"
app:cardCornerRadius="#dimen/padding_4dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/padding_8dp"
android:layout_marginRight="#dimen/padding_8dp">
<RelativeLayout
android:id="#+id/insidecardone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="#dimen/padding_4dp">
<TextView
android:id="#+id/constant_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/padding_4dp"
android:text="Charge per day"
android:textSize="#dimen/text_size_big_16" />
<EditText
android:id="#+id/tvRentPerday"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:hint="Rs. "
android:gravity="center"
android:inputType="number"
android:maxLength="4"
android:textColor="#android:color/black"
android:textSize="#dimen/text_size_big_16" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/insidecardtwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/insidecardone"
android:layout_margin="#dimen/padding_4dp">
<TextView
android:id="#+id/con_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Duration (Days)"
android:textSize="#dimen/text_size_big_16" />
<TextView
android:id="#+id/num_days"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:gravity="center_horizontal"
android:paddingEnd="#dimen/padding_16dp"
android:paddingRight="#dimen/padding_24dp"
android:text="10"
android:textSize="#dimen/text_size_big_16"
/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/insidecardtwo"
android:layout_margin="#dimen/padding_8dp"
android:background="#color/grey_lighter" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/insidecardtwo"
android:layout_margin="#dimen/padding_4dp"
android:paddingBottom="#dimen/padding_8dp"
android:paddingTop="#dimen/padding_24dp">
<TextView
android:id="#+id/total_constant"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="#dimen/padding_4dp"
android:gravity="center_vertical"
android:text="Total Amount"
android:textSize="#dimen/text_size_big_16" />
<TextView
android:id="#+id/tvAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:gravity="center_vertical"
android:textColor="#ff4f00"
android:textSize="#dimen/text_size_big_16"
android:textStyle="bold" />
<TextView
android:id="#+id/total_constant_mutterfly"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/total_constant"
android:paddingTop="#dimen/padding_4dp"
android:text="#string/process_fee_text"
android:textColor="#android:color/darker_gray"
android:textSize="8sp" />
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/middlecard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/firstcard"
android:layout_marginBottom="#dimen/padding_8dp"
android:layout_marginLeft="#dimen/padding_8dp"
android:layout_marginRight="#dimen/padding_8dp"
app:cardCornerRadius="#dimen/padding_4dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/padding_8dp"
android:layout_marginLeft="#dimen/padding_8dp"
android:layout_marginRight="#dimen/padding_8dp">
<RelativeLayout
android:id="#+id/middlecard_relative"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="#dimen/padding_4dp">
<TextView
android:id="#+id/deposite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="#dimen/padding_4dp"
android:gravity="center_vertical"
android:text="Deposit"
android:textSize="#dimen/text_size_big_16" />
<TextView
android:id="#+id/knowmore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/deposite"
android:text="#string/txt_know_more"
android:layout_marginTop="#dimen/padding_8dp"
android:textSize="#dimen/text_size_extra_extra_small_10"
/>
<CheckBox
android:id="#+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:inputType="number"
android:paddingEnd="#dimen/padding_16dp"
android:paddingRight="#dimen/padding_16dp"
android:textColor="#android:color/black"
android:textSize="#dimen/text_size_big_16" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/middletwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/middlecard_relative"
android:layout_margin="#dimen/padding_4dp"
android:visibility="gone"
>
<TextView
android:id="#+id/middle_con_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Charge (Rs.)"
android:textSize="#dimen/text_size_big_16" />
<EditText
android:id="#+id/etDeposit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:gravity="center"
android:paddingEnd="#dimen/padding_16dp"
android:paddingRight="#dimen/padding_16dp"
android:hint="1000"
android:maxLength="4"
android:inputType="number"
android:textSize="#dimen/text_size_big_16"
/>
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/seccard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/middlecard"
android:layout_marginBottom="#dimen/padding_8dp"
android:layout_marginLeft="#dimen/padding_8dp"
android:layout_marginRight="#dimen/padding_8dp"
app:cardCornerRadius="#dimen/padding_4dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="#+id/describe_constant_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="#dimen/padding_8dp"
android:text="Describe Your item"
android:textColor="#ff4f00"
android:textStyle="bold" />
<RelativeLayout
android:id="#+id/rlTohide"
android:layout_marginTop="#dimen/padding_4dp"
android:layout_width="160dp"
android:layout_height="120dp"
android:background="#drawable/greyborder_transparentbg"
>
<ImageView
android:id="#+id/img1"
android:layout_centerInParent="true"
android:layout_width="40dp"
android:src="#drawable/addimg"
android:layout_height="40dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/img1"
android:text="(Optional)"
android:textSize="#dimen/text_size_extra_extra_small_10"
android:textColor="#color/text_grey_opc"
android:layout_centerInParent="true"
/>
</RelativeLayout>
<ImageView
android:visibility="gone"
android:id="#+id/imgResource"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center"
android:layout_marginTop="#dimen/padding_8dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/padding_8dp"
android:layout_marginRight="#dimen/padding_8dp"
android:layout_marginTop="180dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/insidecardone"
android:layout_margin="#dimen/padding_4dp"
android:layout_marginLeft="#dimen/padding_8dp"
android:layout_marginRight="#dimen/padding_8dp">
<TextView
android:id="#+id/con_product_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="8dp"
android:text="Name Of Product"
android:textSize="#dimen/text_size_big_16" />
<EditText
android:id="#+id/product_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_toEndOf="#+id/con_product_name"
android:layout_toRightOf="#+id/con_product_name"
android:layout_alignParentRight="true"
android:hint="E.g. Nikon DSLR"
android:paddingEnd="#dimen/padding_16dp"
android:paddingRight="#dimen/padding_16dp"
android:maxLength="30"
android:inputType="textPersonName"
android:layout_marginLeft="#dimen/padding_16dp"
android:layout_marginStart="#dimen/padding_16dp"
android:textColor="#android:color/black"
android:textSize="#dimen/text_size_big_16"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/insidecardtwo"
android:layout_margin="#dimen/padding_4dp"
android:layout_marginBottom="#dimen/padding_8dp"
android:layout_marginLeft="#dimen/padding_8dp"
android:layout_marginRight="#dimen/padding_8dp">
<TextView
android:id="#+id/Description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Description :"
android:textSize="#dimen/text_size_big_16" />
<EditText
android:id="#+id/desc_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/Description"
android:hint="E.g. Comes with 18-55 mm lens, charger and carry case"
android:layout_marginTop="#dimen/padding_8dp"
android:background="#drawable/white_border_request_screen"
android:textColor="#android:color/darker_gray"
android:textSize="#dimen/text_size_big_16" />
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
</ScrollView>
<Button
android:id="#+id/makeOffer"
android:layout_width="match_parent"
android:layout_height="#dimen/padding_48dp"
android:layout_alignParentBottom="true"
android:background="#color/new_primary_text"
android:padding="#dimen/padding_8dp"
android:text="#string/txt_make_offr"
android:textColor="#android:color/white"
android:textSize="#dimen/text_size_18"
/>
</RelativeLayout>
Android Manifest
<activity
android:name=".MyActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"/>
I am working on the layout since last night and I tried almost solution which I known. I am new in Android so please suggest me what is wrong with this layout.
this "fillViewport" work for another screen but with this screen it's not working.
Add android:windowSoftInputMode="stateHidden|adjustResize" to your <activity> tag in AndroidManifest.xml file. This will cause the screen to be resized to the left over space after the soft keyboard is shown. So, you will be able to scroll easily.
One more thing set property of ScrollView to the android:layout_above to the Button on the bottom of the page.
UpDate :
add this line to your ScrollView.
android:layout_above="#+id/makeOffer"
like this way
<ScrollView
android:id="#+id/scroll"
android:layout_width="wrap_content"
android:layout_below="#+id/toolbar"
android:layout_height="wrap_content"
android:fillViewport="true"
android:layout_above="#+id/makeOffer">
ScreenShot :

Why first click on the ImageView is not working?

I have read through other posts. I can't able to find the solution still.
I tried putting
android:focusableInTouchMode="false"
android:focusable="false"
not worked.
I have included
android:clickable="true"
not worked.
In Java code, I have included
imgLeft.setOnFocusChangeListener(new View.OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
v.performClick();
}
}
});
aside with the onClickListener().
But still it didn't worked.
Here is my rough layout structure and position of the image view.
<RelativeLayout>
<FrameLayout>
<LinearLayout>
<Relativelayout>
<LineatLayout/>
<LinearLayout>
<LinearLayout>
<ImageView <--- This is the I needed to click.
android:id="#+id/imgLeft"
android:layout_width="wrap_content"
android:layout_height="#dimen/title_img_width"
android:src="#drawable/left"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</Relativelayout>
</LinearLayout>
</FrameLayout>
</Relativelayout>
I am using setOnClickListener for handling the click event.
imgLeft.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
//some function here <-- **This function triggers only after the second click**
}
});
NOTE:
I thoroughly checked the other stackoverflow posts. But none of them solved the problem.. is there any solution for the above
UPDATE: Original code:
<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rl_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bg_image" >
<FrameLayout
android:id="#+id/layoutConfiguration"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="#drawable/bg_image"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/menu_header_height" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1" >
<LinearLayout
android:id="#+id/ll_menu"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".2"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:layout_width="#dimen/menu_top_icon"
android:layout_height="match_parent"
android:layout_gravity="center"
android:padding="5dp"
android:src="#drawable/menu" />
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.68"
android:fontFamily="Oswald-Regular.ttf"
android:gravity="center"
android:text="Connect Bluetooths"
android:textColor="#fff"
android:textSize="#dimen/menu_tital_textsize" />
<!-- android:padding="#dimen/menu_tital_padding" -->
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".2"
android:gravity="center"
android:padding="15dp"
android:text=""
android:textColor="#fff"
android:textSize="25dp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/ll_sole"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/tital_margin_top"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:weightSum="1" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:orientation="vertical" >
<TextView
android:id="#+id/tv_leftBattery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:fontFamily="Raleway-Regular.ttf"
android:gravity="center"
android:text="100%"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/holo_red_dark"
android:textSize="16sp"
android:visibility="gone" />
<ImageView
android:id="#+id/imgLeftBluetooth"
android:layout_width="wrap_content"
android:layout_height="#dimen/title_img_width"
android:src="#drawable/left" />
<TextView
android:id="#+id/tv_leftBluetooth"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:fontFamily="Raleway-Regular.ttf"
android:gravity="center"
android:text="Not Connected"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:orientation="vertical" >
<TextView
android:id="#+id/tv_rightBattery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:fontFamily="Raleway-Regular.ttf"
android:gravity="center"
android:text="100%"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/holo_red_dark"
android:textSize="16sp"
android:visibility="gone" />
<ImageView
android:id="#+id/imgRightBluetooth"
android:layout_width="wrap_content"
android:layout_height="#dimen/title_img_width"
android:layout_marginTop="5dp"
android:src="#drawable/right" />
<TextView
android:id="#+id/tv_rightBluetooth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:fontFamily="Raleway-Regular.ttf"
android:gravity="center"
android:text="Not Connected"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingTop="#dimen/menu_tital_padding" >
<ToggleButton
android:id="#+id/toggleButton_connectBluetooth"
android:layout_width="#dimen/title_img_height"
android:layout_height="#dimen/title_text_height"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#drawable/toggle_selector"
android:checked="false"
android:padding="5dp"
android:text=""
android:textOff=""
android:textOn="" />
<TextView
android:id="#+id/tv_toggle_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="7dp"
android:text="Connect Left Bluetooths Only"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#android:color/white" />
</LinearLayout>
</LinearLayout>
<FrameLayout
android:id="#+id/fl_balloon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="-15dp"
android:gravity="center"
android:visibility="gone" >
<ImageView
android:id="#+id/imageView2"
android:layout_width="#dimen/balloon_width"
android:layout_height="#dimen/balloon_height"
android:layout_gravity="center"
android:scaleType="fitXY"
android:src="#drawable/balloon" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="7dp"
android:fontFamily="Oswald-Regular.ttf"
android:gravity="center"
android:text="Pair"
android:textColor="#android:color/white" />
</FrameLayout>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:fontFamily="Oswald-Regular.ttf"
android:text="Configure Bluetooths"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="#dimen/menu_tital_textsize"
android:visibility="gone" />
<Button
android:id="#+id/btn_next"
android:layout_width="wrap_content"
android:layout_height="#dimen/menu_top_icon"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="29dp"
android:background="#drawable/button_box"
android:padding="3dp"
android:text="Continue"
android:textColor="#android:color/white"
android:textSize="15dp"
android:textStyle="bold" />
</RelativeLayout>
</LinearLayout>
</FrameLayout>
</RelativeLayout>
The id of the clicks that were performed are
imgLeftBluetooth and imgRightBluetooth. These two imageviews were triggering only after 2nd click.
Its simple .You can try this
Just add android:onClick="clicking" in your ImageView (XML)
Then
public void clicking(View v)
{
Toast.makeText(v.getContext(),"Clicking On Image",Toast.LENGTH_LONG).show();
}
Edited
YOUR_IMAGE_VIEW_OBJ.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// Do your Staff
}
});
Android ImageView's onClickListener does not work

How to create Relative layout Dynamicaly

I want to generate the relative layout dynamically So that i can repeat the data as much as many times i get data from the server .The layout id that i want to create dynamically are depart_flight_details_duration,passenger_details_layout.How could create them in a loop so that it will be repeated more than one .Please help me on this i am new in android.
XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imgLogo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginRight="5dip"
android:padding="3dip"
android:src="#drawable/logo_demo" />
<ScrollView
android:id="#+id/main_scroll_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/imgLogo" >
<RelativeLayout
android:id="#+id/main_ScrollView_Container"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:id="#+id/trip_details_main"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:background="#drawable/flight_detail"
android:gravity="center_vertical" >
<TextView
android:id="#+id/trip_locations"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:text="Delhi to Hydrabad"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/depart_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/trip_locations"
android:layout_marginLeft="5dp"
android:text="18 Sep 2013"
android:textColor="#FFFFFF"
android:textSize="15sp" />
<ImageView
android:id="#+id/imgRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="12dp"
android:src="#drawable/cal" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/travel_itin_header"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_below="#+id/trip_details_main"
android:layout_marginTop="2dp"
android:background="#drawable/gray"
android:gravity="center_vertical" >
<TextView
android:id="#+id/itinerary_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="90dp"
android:layout_marginTop="5dp"
android:text="Itinerary Details"
android:textColor="#FFFFFF"
android:textSize="15sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/passenger_details_layout"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_below="#+id/travel_itin_header"
android:layout_marginTop="2dp"
android:background="#drawable/gray"
android:gravity="center_vertical" >
<ImageView
android:id="#+id/pax_image"
android:layout_width="wrap_content"
android:layout_height="50dip"
android:layout_alignParentLeft="true"
android:padding="3dip"
android:src="#drawable/black_man" />
<TextView
android:id="#+id/first_pax_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/pax_image"
android:layout_marginLeft="12dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/pax_image"
android:text=" XXX XXX XXX"
android:textColor="#FFFFFF"
android:textSize="15sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imgRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/first_pax_name"
android:layout_alignParentRight="true"
android:src="#drawable/arrow2" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/depart_flight_details_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/passenger_details_layout"
android:layout_marginTop="2dp"
android:background="#drawable/small_search" >
<ImageView
android:id="#+id/flight_depart_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:padding="3dip"
android:src="#drawable/dep" />
<TextView
android:id="#+id/depart_return_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/flight_depart_image"
android:layout_marginLeft="12dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#+id/arrow_image"
android:layout_toRightOf="#+id/flight_depart_image"
android:text="Delhi to Hydrabad"
android:textColor="#FFFFFF"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="#+id/one_way_date_and_duration_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/depart_return_location"
android:layout_marginLeft="12dp"
android:layout_toRightOf="#+id/flight_depart_image"
android:text="18 Sep 2013 09:45 | Duration 2:45"
android:textColor="#FFFFFF"
android:textSize="12sp" />
<ImageView
android:id="#+id/arrow_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/depart_return_location"
android:layout_alignParentRight="true"
android:layout_marginTop="10dp"
android:src="#drawable/arrow2" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/travel_agency_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/depart_flight_details_duration"
android:layout_marginTop="2dp"
android:background="#drawable/travelagency_bg" >
<TextView
android:id="#+id/travel_agency_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:text="Travel Agency"
android:textColor="#676767"
android:textSize="15sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tarvel_agency_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/travel_agency_header"
android:layout_marginTop="2dp" >
<ImageView
android:id="#+id/agent_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:src="#drawable/logo" />
<ImageView
android:id="#+id/mobile_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/agent_logo"
android:src="#drawable/mobile" />
<ImageView
android:id="#+id/at_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/mobile_logo"
android:src="#drawable/at" />
<ImageView
android:id="#+id/email_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/at_logo"
android:src="#drawable/at" />
<TextView
android:id="#+id/travel_agency_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/agent_logo"
android:layout_marginLeft="5dp"
android:text="Address : XXXXXXXX"
android:textColor="#676767" />
<TextView
android:id="#+id/travel_agency_fax"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/travel_agency_address"
android:layout_marginLeft="5dp"
android:layout_marginTop="2dp"
android:text="Fax : XXXXXXXX"
android:textColor="#676767" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/genral_remarks_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tarvel_agency_details"
android:layout_marginTop="2dp"
android:background="#drawable/general_remar" >
<TextView
android:id="#+id/genral_remark_header_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:text="Genral Remarks"
android:textColor="#676767"
android:textSize="15sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/genral_remark_text_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/genral_remarks_header"
android:layout_marginTop="2dp" >
<TextView
android:id="#+id/genral_remark_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="center_vertical"
android:text="HAVE A NICE TRIP"
android:textColor="#676767" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
You have to use custom listview.
And for two listview in one layout see this link Link
A Simple Program for LayoutInflater from here
a-make this layout as your activity_main.xml-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</LinearLayout>
b-this is the hidden layout which we will add dynamically,save it as hidden_layout.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/hidden_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="#+id/text_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello, this is the inflated text of hidden layout"/>
<EditText
android:id="#+id/edit_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello, this is your name"/>
</LineraLayout>
c- Now this is the code for main activity-
public class MainActivity extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
for(int i=0;i<numberOfRows;i++){
LinearLayout main = (LinearLayout)findViewById(R.id.main_layout);
View view = getLayoutInflater().inflate(R.layout.hidden_layout, main,false);
main.addView(view);
}
}
}
RelativeLayout mDisplayBlock = (RelativeLayout)
LayoutInflater.from(getActivity()).inflate(
depart_flight_details_duration, null);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
mDisplayBlock.setLayoutParams(params);
you can add this layout to your main scroll view
main_scroll_view_layout.addView(mDisplayBlock);
just put this code at appropriate place in your code.

Categories

Resources