Android 带搜索的浮动操作栏
我正在尝试通过actionbar中的搜索创建地图布局 以下是我想要实现的目标: 到目前为止,我尝试了cardview,但这不是一个正确的方法。我需要这个东西作为一个真正的动作条。也许使用自定义工具栏会有所帮助,但我需要一些建议Android 带搜索的浮动操作栏,android,android-actionbar,Android,Android Actionbar,我正在尝试通过actionbar中的搜索创建地图布局 以下是我想要实现的目标: 到目前为止,我尝试了cardview,但这不是一个正确的方法。我需要这个东西作为一个真正的动作条。也许使用自定义工具栏会有所帮助,但我需要一些建议 <android.support.v7.widget.CardView android:layout_width="match_parent" android:layout_height="wrap_content" android:lay
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
app:cardCornerRadius="11dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_search" />
<EditText
android:id="@+id/editText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:ems="10"
android:inputType="textPersonName"
android:maxLines="1"
android:background="@android:color/transparent"
android:hint="@string/search_location_hint"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/imageView5"
app:layout_constraintStart_toEndOf="@+id/view"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_menu" />
<View
android:id="@+id/view"
android:layout_width="1dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="@color/gray"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageView4"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
对于浮动工具栏:使用工具栏小部件&从左、上、右提供一些边距
对于圆角:使用工具栏中的形状背景。尝试使用相对布局