我目前正在学习如何将我的应用程序转换为Material设计,现在我有点卡住了.我添加了工具栏,我的导航抽屉覆盖了所有内容.
我现在正在尝试创建一个类似于材料指南中的可扩展搜索:

这就是我现在所拥有的,我无法弄清楚如何使它如上所述:

这是我的菜单xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_search"
android:icon="@android:drawable/ic_menu_search"
android:title="Search"
app:showAsAction="always"
app:actionViewClass="android.support.v7.widget.SearchView" />
</menu>
Run Code Online (Sandbox Code Playgroud)
这有效,我得到一个扩展到SearchView的菜单项,我可以很好地过滤我的列表.虽然看起来不像第一张照片.
我尝试使用MenuItemCompat.setOnActionExpandListener(),R.id.action_search所以我可以将主页图标更改为后退箭头,但这似乎不起作用.侦听器中没有任何内容被触发.即使它起作用,它仍然不会非常接近第一张图像.
如何在新的appcompat工具栏中创建看起来像材质指南的SearchView?
android toolbar android-appcompat searchview material-design
我正在使用最近发布的Android设计支持库来显示带有EditTexts的浮动标签.但我面临的问题是,在渲染UI时,EditText上的提示没有显示,但是在我专注于EditTexts之后我看到了Hint.
我的布局如下:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="@+id/ScrollView01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin">
<android.support.design.widget.TextInputLayout
android:id="@+id/name_et_textinputlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_vertical_margin">
<EditText
android:id="@+id/FeedBackerNameET"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/feedbackname"
android:inputType="textPersonName|textCapWords" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/email_textinputlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/FeedBackerEmailET"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/feedbackemail"
android:inputType="textEmailAddress" />
</android.support.design.widget.TextInputLayout>
<Spinner
android:id="@+id/SpinnerFeedbackType"
android:layout_width="fill_parent"
android:layout_height="48dp"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:entries="@array/feedbacktypelist"
android:prompt="@string/feedbacktype" />
<android.support.design.widget.TextInputLayout
android:id="@+id/body_textinputlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/EditTextFeedbackBody"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/feedbackbody"
android:inputType="textMultiLine|textCapSentences"
android:lines="5" />
</android.support.design.widget.TextInputLayout>
<CheckBox
android:id="@+id/CheckBoxFeedBackResponse"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:text="@string/feedbackresponse" />
<Button
android:id="@+id/ButtonSendFeedback" …Run Code Online (Sandbox Code Playgroud) 单击"搜索"菜单项时,从顶部的SearchView下来,占用工具栏的整个空间:

我找到了一些实现这个的库: Eugene Horan的Android Material SearchView 和krishnakapil的MaterialSearchView.但它们与WhatsApp不同.
这个问题可能看起来很奇怪,我找不到怎么做的方法.所以我的问题是如何实现WhatsApp之类的材料设计SearchView来自顶级?
我试图像这样改变EditText中的文本颜色
<EditText
android:id="@+id/txtUserName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:gravity="right"
android:hint="@string/hint_user_name"
android:textColor="#B49228FF" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/txtPassword"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="50px"
android:gravity="right"
android:hint="@string/hint_password"
android:inputType="textPassword"
android:textColor="#B49228" />
Run Code Online (Sandbox Code Playgroud)
但它没有改变这种颜色#B49228就像这样的金色

我的设备 : HoneyWell Delphine 70e