我正在嘗試創(chuàng)建一個(gè)與 Google 照片應(yīng)用程序中的工具欄具有相似樣式的搜索欄 - 即用陰影四舍五入。我們使用 Material 庫中的 TextInputLayout 作為片段的唯一子元素(它在父片段的頂部膨脹)。以下是我目前所擁有的(一旦我可以購買海拔高度,我就有一個(gè)可用作背景的可繪制對象,為了清楚起見,我省略了它)<?xml version="1.0" encoding="utf-8"?><androidx.constraintlayout.widget.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" tools:context=".Fragments.SearchFragment"> <com.google.android.material.textfield.TextInputLayout android:id="@+id/searchTextInputLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="8dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> <com.google.android.material.textfield.TextInputEditText android:id="@+id/searchTextInputEditText" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:paddingStart="24dp" android:paddingEnd="24dp" android:background="#ffffff" android:elevation="20dp" android:drawableStart="@drawable/ic_menu_black_24dp" android:hint="Search" /> </com.google.android.material.textfield.TextInputLayout></androidx.constraintlayout.widget.ConstraintLayout><!--android:background="@drawable/searchbar_rounded"-->我在這里遺漏了一些明顯的東西,還是這是 TextInputLayout 的限制?
1 回答

素胚勾勒不出你
TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超9個(gè)贊
將 textView 放在 cardView 里面,它肯定會(huì)產(chǎn)生陰影 cardView 的例子
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="6dp"
card_view:cardUseCompatPadding="true"
card_view:cardElevation="4dp"
card_view:cardCornerRadius="3dp">
添加回答
舉報(bào)
0/150
提交
取消