how to show drop down of AutoCompleteTextView behind of a view?












0















I used an AutoCompleteTextView in my Service. after user type in AutoCompleteTextView, a drop down shown like this:



before



drop down is shown top of service layout but what I want is shown behind of that like this:



after



service use this layout:



<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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="wrap_content"
android:layout_height="wrap_content"

>


<View
android:id="@+id/bg"
android:layout_width="64dp"
android:layout_height="64dp"
android:background="@drawable/floating_service_bg"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>

<android.support.constraint.ConstraintLayout
android:id="@+id/collapse_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="@id/bg"
app:layout_constraintLeft_toLeftOf="@id/bg"
app:layout_constraintTop_toTopOf="@id/bg"
>

<ImageView
android:id="@+id/icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_margin="8dp"
android:src="@drawable/star"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

<ImageView
android:id="@+id/close_btn"
android:layout_width="20dp"
android:layout_height="20dp"
android:background="@drawable/ic_close"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription"/>
</android.support.constraint.ConstraintLayout>

<View
android:id="@+id/drop_down_anchor"
android:layout_width="0dp"
android:layout_height="0.5dp"
android:layout_margin="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>

<LinearLayout
android:id="@+id/expanded_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="horizontal"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/bg"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintLeft_toRightOf="@id/collapse_view"
app:layout_constraintRight_toRightOf="@id/bg"
app:layout_constraintTop_toTopOf="@id/bg">


<AutoCompleteTextView
android:id="@+id/searchBox"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="@color/transparent"
android:dropDownAnchor="@id/drop_down_anchor"
android:gravity="left"
android:hint="@string/searchboxHint"
android:imeOptions="actionDone"
android:inputType="textPhonetic"
android:padding="15dip"
android:selectAllOnFocus="false"
android:singleLine="true"
android:textColor="#000"
android:textColorHint="#a5a5a5"
android:textIsSelectable="true"
android:textSize="16sp"

/>

<ImageView
android:id="@+id/search_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:src="@drawable/ic_search_24dp"
android:visibility="visible"

/>


</LinearLayout>


</android.support.constraint.ConstraintLayout>


and DropDownAdapter class:



class DropDownAdapter extends ArrayAdapter<String> {
ArrayList<String> wordList;
ArrayList<String> meanList;

public DropDownAdapter(ArrayList<String> words, ArrayList<String> means) {
super(context, R.layout.drop_down_layout, words);
this.wordList = words;
this.meanList = means;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(LAYOUT_INFLATER_SERVICE);

View rowView = (View) inflater.inflate(R.layout.drop_down_layout,
parent, false);

TextView leftTextView = (TextView) rowView.findViewById(R.id.item_word);
TextView rightTextView = (TextView) rowView.findViewById(R.id.item_mean);
LinearLayout dropDownItem = (LinearLayout) rowView.findViewById(R.id.drop_down_item);

final int pos = position;

leftTextView.setText(wordList.get(pos));
rightTextView.setText(meanList.get(pos));
return rowView;
}

}


can you suggest me a solution, please?










share|improve this question

























  • I see you have specified android:dropDownAnchor="@id/drop_down_anchor". What is this drop_down_anchor? Can you put the complete Layout XML?

    – Anirban Roy
    Jan 1 at 17:43











  • @Anirban Roy drop_down_anchor is id of layout that i want drop down shown based of that position.

    – Hadi Ahmadi
    Jan 1 at 18:57
















0















I used an AutoCompleteTextView in my Service. after user type in AutoCompleteTextView, a drop down shown like this:



before



drop down is shown top of service layout but what I want is shown behind of that like this:



after



service use this layout:



<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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="wrap_content"
android:layout_height="wrap_content"

>


<View
android:id="@+id/bg"
android:layout_width="64dp"
android:layout_height="64dp"
android:background="@drawable/floating_service_bg"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>

<android.support.constraint.ConstraintLayout
android:id="@+id/collapse_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="@id/bg"
app:layout_constraintLeft_toLeftOf="@id/bg"
app:layout_constraintTop_toTopOf="@id/bg"
>

<ImageView
android:id="@+id/icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_margin="8dp"
android:src="@drawable/star"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

<ImageView
android:id="@+id/close_btn"
android:layout_width="20dp"
android:layout_height="20dp"
android:background="@drawable/ic_close"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription"/>
</android.support.constraint.ConstraintLayout>

<View
android:id="@+id/drop_down_anchor"
android:layout_width="0dp"
android:layout_height="0.5dp"
android:layout_margin="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>

<LinearLayout
android:id="@+id/expanded_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="horizontal"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/bg"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintLeft_toRightOf="@id/collapse_view"
app:layout_constraintRight_toRightOf="@id/bg"
app:layout_constraintTop_toTopOf="@id/bg">


<AutoCompleteTextView
android:id="@+id/searchBox"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="@color/transparent"
android:dropDownAnchor="@id/drop_down_anchor"
android:gravity="left"
android:hint="@string/searchboxHint"
android:imeOptions="actionDone"
android:inputType="textPhonetic"
android:padding="15dip"
android:selectAllOnFocus="false"
android:singleLine="true"
android:textColor="#000"
android:textColorHint="#a5a5a5"
android:textIsSelectable="true"
android:textSize="16sp"

/>

<ImageView
android:id="@+id/search_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:src="@drawable/ic_search_24dp"
android:visibility="visible"

/>


</LinearLayout>


</android.support.constraint.ConstraintLayout>


and DropDownAdapter class:



class DropDownAdapter extends ArrayAdapter<String> {
ArrayList<String> wordList;
ArrayList<String> meanList;

public DropDownAdapter(ArrayList<String> words, ArrayList<String> means) {
super(context, R.layout.drop_down_layout, words);
this.wordList = words;
this.meanList = means;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(LAYOUT_INFLATER_SERVICE);

View rowView = (View) inflater.inflate(R.layout.drop_down_layout,
parent, false);

TextView leftTextView = (TextView) rowView.findViewById(R.id.item_word);
TextView rightTextView = (TextView) rowView.findViewById(R.id.item_mean);
LinearLayout dropDownItem = (LinearLayout) rowView.findViewById(R.id.drop_down_item);

final int pos = position;

leftTextView.setText(wordList.get(pos));
rightTextView.setText(meanList.get(pos));
return rowView;
}

}


can you suggest me a solution, please?










share|improve this question

























  • I see you have specified android:dropDownAnchor="@id/drop_down_anchor". What is this drop_down_anchor? Can you put the complete Layout XML?

    – Anirban Roy
    Jan 1 at 17:43











  • @Anirban Roy drop_down_anchor is id of layout that i want drop down shown based of that position.

    – Hadi Ahmadi
    Jan 1 at 18:57














0












0








0








I used an AutoCompleteTextView in my Service. after user type in AutoCompleteTextView, a drop down shown like this:



before



drop down is shown top of service layout but what I want is shown behind of that like this:



after



service use this layout:



<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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="wrap_content"
android:layout_height="wrap_content"

>


<View
android:id="@+id/bg"
android:layout_width="64dp"
android:layout_height="64dp"
android:background="@drawable/floating_service_bg"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>

<android.support.constraint.ConstraintLayout
android:id="@+id/collapse_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="@id/bg"
app:layout_constraintLeft_toLeftOf="@id/bg"
app:layout_constraintTop_toTopOf="@id/bg"
>

<ImageView
android:id="@+id/icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_margin="8dp"
android:src="@drawable/star"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

<ImageView
android:id="@+id/close_btn"
android:layout_width="20dp"
android:layout_height="20dp"
android:background="@drawable/ic_close"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription"/>
</android.support.constraint.ConstraintLayout>

<View
android:id="@+id/drop_down_anchor"
android:layout_width="0dp"
android:layout_height="0.5dp"
android:layout_margin="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>

<LinearLayout
android:id="@+id/expanded_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="horizontal"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/bg"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintLeft_toRightOf="@id/collapse_view"
app:layout_constraintRight_toRightOf="@id/bg"
app:layout_constraintTop_toTopOf="@id/bg">


<AutoCompleteTextView
android:id="@+id/searchBox"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="@color/transparent"
android:dropDownAnchor="@id/drop_down_anchor"
android:gravity="left"
android:hint="@string/searchboxHint"
android:imeOptions="actionDone"
android:inputType="textPhonetic"
android:padding="15dip"
android:selectAllOnFocus="false"
android:singleLine="true"
android:textColor="#000"
android:textColorHint="#a5a5a5"
android:textIsSelectable="true"
android:textSize="16sp"

/>

<ImageView
android:id="@+id/search_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:src="@drawable/ic_search_24dp"
android:visibility="visible"

/>


</LinearLayout>


</android.support.constraint.ConstraintLayout>


and DropDownAdapter class:



class DropDownAdapter extends ArrayAdapter<String> {
ArrayList<String> wordList;
ArrayList<String> meanList;

public DropDownAdapter(ArrayList<String> words, ArrayList<String> means) {
super(context, R.layout.drop_down_layout, words);
this.wordList = words;
this.meanList = means;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(LAYOUT_INFLATER_SERVICE);

View rowView = (View) inflater.inflate(R.layout.drop_down_layout,
parent, false);

TextView leftTextView = (TextView) rowView.findViewById(R.id.item_word);
TextView rightTextView = (TextView) rowView.findViewById(R.id.item_mean);
LinearLayout dropDownItem = (LinearLayout) rowView.findViewById(R.id.drop_down_item);

final int pos = position;

leftTextView.setText(wordList.get(pos));
rightTextView.setText(meanList.get(pos));
return rowView;
}

}


can you suggest me a solution, please?










share|improve this question
















I used an AutoCompleteTextView in my Service. after user type in AutoCompleteTextView, a drop down shown like this:



before



drop down is shown top of service layout but what I want is shown behind of that like this:



after



service use this layout:



<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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="wrap_content"
android:layout_height="wrap_content"

>


<View
android:id="@+id/bg"
android:layout_width="64dp"
android:layout_height="64dp"
android:background="@drawable/floating_service_bg"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>

<android.support.constraint.ConstraintLayout
android:id="@+id/collapse_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="@id/bg"
app:layout_constraintLeft_toLeftOf="@id/bg"
app:layout_constraintTop_toTopOf="@id/bg"
>

<ImageView
android:id="@+id/icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_margin="8dp"
android:src="@drawable/star"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

<ImageView
android:id="@+id/close_btn"
android:layout_width="20dp"
android:layout_height="20dp"
android:background="@drawable/ic_close"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription"/>
</android.support.constraint.ConstraintLayout>

<View
android:id="@+id/drop_down_anchor"
android:layout_width="0dp"
android:layout_height="0.5dp"
android:layout_margin="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>

<LinearLayout
android:id="@+id/expanded_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="horizontal"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/bg"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintLeft_toRightOf="@id/collapse_view"
app:layout_constraintRight_toRightOf="@id/bg"
app:layout_constraintTop_toTopOf="@id/bg">


<AutoCompleteTextView
android:id="@+id/searchBox"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="@color/transparent"
android:dropDownAnchor="@id/drop_down_anchor"
android:gravity="left"
android:hint="@string/searchboxHint"
android:imeOptions="actionDone"
android:inputType="textPhonetic"
android:padding="15dip"
android:selectAllOnFocus="false"
android:singleLine="true"
android:textColor="#000"
android:textColorHint="#a5a5a5"
android:textIsSelectable="true"
android:textSize="16sp"

/>

<ImageView
android:id="@+id/search_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:src="@drawable/ic_search_24dp"
android:visibility="visible"

/>


</LinearLayout>


</android.support.constraint.ConstraintLayout>


and DropDownAdapter class:



class DropDownAdapter extends ArrayAdapter<String> {
ArrayList<String> wordList;
ArrayList<String> meanList;

public DropDownAdapter(ArrayList<String> words, ArrayList<String> means) {
super(context, R.layout.drop_down_layout, words);
this.wordList = words;
this.meanList = means;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(LAYOUT_INFLATER_SERVICE);

View rowView = (View) inflater.inflate(R.layout.drop_down_layout,
parent, false);

TextView leftTextView = (TextView) rowView.findViewById(R.id.item_word);
TextView rightTextView = (TextView) rowView.findViewById(R.id.item_mean);
LinearLayout dropDownItem = (LinearLayout) rowView.findViewById(R.id.drop_down_item);

final int pos = position;

leftTextView.setText(wordList.get(pos));
rightTextView.setText(meanList.get(pos));
return rowView;
}

}


can you suggest me a solution, please?







android dropdown autocompletetextview






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 1 at 19:13







Hadi Ahmadi

















asked Jan 1 at 17:16









Hadi AhmadiHadi Ahmadi

155




155













  • I see you have specified android:dropDownAnchor="@id/drop_down_anchor". What is this drop_down_anchor? Can you put the complete Layout XML?

    – Anirban Roy
    Jan 1 at 17:43











  • @Anirban Roy drop_down_anchor is id of layout that i want drop down shown based of that position.

    – Hadi Ahmadi
    Jan 1 at 18:57



















  • I see you have specified android:dropDownAnchor="@id/drop_down_anchor". What is this drop_down_anchor? Can you put the complete Layout XML?

    – Anirban Roy
    Jan 1 at 17:43











  • @Anirban Roy drop_down_anchor is id of layout that i want drop down shown based of that position.

    – Hadi Ahmadi
    Jan 1 at 18:57

















I see you have specified android:dropDownAnchor="@id/drop_down_anchor". What is this drop_down_anchor? Can you put the complete Layout XML?

– Anirban Roy
Jan 1 at 17:43





I see you have specified android:dropDownAnchor="@id/drop_down_anchor". What is this drop_down_anchor? Can you put the complete Layout XML?

– Anirban Roy
Jan 1 at 17:43













@Anirban Roy drop_down_anchor is id of layout that i want drop down shown based of that position.

– Hadi Ahmadi
Jan 1 at 18:57





@Anirban Roy drop_down_anchor is id of layout that i want drop down shown based of that position.

– Hadi Ahmadi
Jan 1 at 18:57












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53997418%2fhow-to-show-drop-down-of-autocompletetextview-behind-of-a-view%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53997418%2fhow-to-show-drop-down-of-autocompletetextview-behind-of-a-view%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith