1
在我的片段(不在ToolBar中)我有SearchView组件。 这里片段在XML布局:如何在searchView和下拉列表之间添加空格(egheight = 20dp)?
<?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="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.SearchView
android:id="@+id/searchView"
style="@style/Widget.AppCompat.SearchView.ActionBar"
android:layout_width="0dp"
android:layout_height="30dp"
android:background="@drawable/search_view_bg"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:searchHintIcon="@null" />
</android.support.constraint.ConstraintLayout>
这里我的下拉的项目布局的xml:
<?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="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/standard_min_height_container">
<ImageView
android:id="@+id/catalogImageView"
android:layout_width="28dp"
android:layout_height="28dp"
android:src="@drawable/suggestion_icon"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_goneMarginStart="@dimen/standard_margin" />
<TextView
android:id="@+id/catalogNameTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:text="Test text View Test text "
android:textColor="@android:color/black"
android:textSize="15sp"
app:layout_constraintBottom_toBottomOf="@+id/catalogImageView"
app:layout_constraintLeft_toRightOf="@+id/catalogImageView"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/catalogImageView" />
<View
android:id="@+id/textView2"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="@color/divider_color"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="@+id/catalogImageView"
app:layout_constraintRight_toRightOf="@+id/catalogNameTextView" />
</android.support.constraint.ConstraintLayout>
这里的Java代码在我的片段:
searchView = view.findViewById(R.id.searchView);
SearchManager sMng = context.getSystemService(Context.SEARCH_SERVICE);
searchView.setSearchableInfo(sMng.getSearchableInfo(getComponentName()));
searchView.setSuggestionsAdapter(new SearchCatalogSuggestionsAdapter(ctx);
而且这里的结果是:
但我需要在searchView和下拉列表之间添加空格(高度= 20dp)?我如何做到这一点?
用自己的身高更换100 –