我正在尝试重新创建Airbnb Android应用中的搜索框.所以我使用CoorinatorLayout与工具栏和RecyclerView.
但是当我在协调器中插入一些东西时,除了这两件事之外,它并没有显示出来.这是我的代码:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/slidingLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/red"
app:layout_scrollFlags="scroll|enterAlways" />
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginTop="20dp"
android:background="@drawable/rounded_background"
android:orientation="horizontal"
android:padding="6dp"
app:layout_scrollFlags="scroll|enterAlways">
<EditText
android:id="@+id/search"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="6"
android:background="@null"
android:fontFamily="sans-serif-light"
android:hint="Unesite grad"
android:paddingLeft="16dp"
android:paddingStart="16dp" />
<ImageView
android:id="@+id/cancelSearch"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="1"
android:padding="10dp"
android:src="@drawable/ic_cancel" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="@id/appbar"
android:background="#ffffff"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
Run Code Online (Sandbox Code Playgroud)
但实际上如果这种方法有效,我会把搜索框放在RecyclerView上面.
我试图将所有内容放在RelativeLayout中,但这不起作用.
编辑:
这是RelativeLayout的代码
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/slidingLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout …Run Code Online (Sandbox Code Playgroud) android android-relativelayout android-coordinatorlayout android-support-design
我为我的Android应用程序制作了一个自定义listView,我在为项目的不同部分创建单独的onClickListener时遇到问题.我的项目有图片和文字.我想要的是根据点击的那些开始不同的活动.
onClick()方法应该启动一个活动,这使我无法在我的DataBinder类的getView()方法中定义.(DataBinder使用自定义布局填充我的listView)
有帮助吗?
谢谢!