相关疑难解决方法(0)

创建看起来像材料设计准则的SearchView

我目前正在学习如何将我的应用程序转换为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

132
推荐指数
7
解决办法
13万
查看次数

TextInputLayout在用户关注它之前没有显示EditText提示

我正在使用最近发布的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)

android material-design android-design-library

94
推荐指数
5
解决办法
4万
查看次数

根据材料设计指南实施SearchView

我一直在寻找根据材料设计指南在活动工具栏(操作栏)中实现搜索视图的方法.

单击搜索图标时,整个工具栏将动画为仅具有白色背景的搜索EditText,并在主视图中显示建议而不是下拉列表.

以下是指南中的屏幕截图: 在此输入图像描述

以下是Gmail收件箱实施的GIF: 在此输入图像描述

我一直在寻找代码示例和教程,但到目前为止我一直没有成功.我该怎么做呢?

android searchview material-design

37
推荐指数
4
解决办法
6万
查看次数

如何实现WhatsApp像材料设计SearchView?

WhatsApp有这样的工具栏: 在此输入图像描述

单击"搜索"菜单项时,从顶部的SearchView下来,占用工具栏的整个空间: 在此输入图像描述

当我尝试实现SearchView时,它看起来像这样: 在此输入图像描述

我找到了一些实现这个的库: Eugene Horan的Android Material SearchViewkrishnakapil的MaterialSearchView.但它们与WhatsApp不同.

这个问题可能看起来很奇怪,我找不到怎么做的方法.所以我的问题是如何实现WhatsApp之类的材料设计SearchView来自顶级?

android whatsapp searchview material-design android-toolbar

3
推荐指数
2
解决办法
2万
查看次数

EditText无法更改文本颜色

我试图像这样改变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

android textcolor android-edittext

1
推荐指数
2
解决办法
5047
查看次数