Android 搜索栏
我希望为我的android应用程序制作一个浮动操作按钮,当点击时它会变成搜索栏 我看到它们变成了Android 搜索栏,android,Android,我希望为我的android应用程序制作一个浮动操作按钮,当点击时它会变成搜索栏 我看到它们变成了操作栏工具栏,但我想用它来搜索。如果您有任何帮助,我们将不胜感激 谢谢 您可以通过3个步骤完成此操作 浮动操作按钮,你可以使用谷歌支持库,我已经解释过了 单击浮动操作按钮时,需要显示工具栏, 为此,您的主页应具有FAB和工具栏,如下所示: <LinearLayout android:id="@+id/mainView" xmlns:android="http://sc
操作栏
工具栏
,但我想用它来搜索。如果您有任何帮助,我们将不胜感激
谢谢 您可以通过3个步骤完成此操作
<LinearLayout android:id="@+id/mainView"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/app_bar"/>
<View android:id="@+id/stripBelowToolbar"
android:layout_height="0dp"
android:layout_width="fill_parent"/>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/rootLayout"
android:layout_height="match_parent"
android:layout_width="match_parent">
<android.support.design.widget.FloatingActionButton
style="@style/fab_style"
android:id="@+id/fabBtn"
android:layout_gravity="bottom|right"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
fab:backgroundTint="@color/sap_uex_dark_yellow"
fab:rippleColor="@color/white"/>
虽然我还没有亲自尝试过,但github上的Fabtransions库看起来可能对您有用。
FloatingActionButton fab = (FloatingActionButton)findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setvisibility(View.VISIBLE)// show the searchbox and bla bla...
}
});