【发布时间】:2016-08-27 14:25:52
【问题描述】:
在我的主屏幕中,我想添加带有导航抽屉的搜索框,但我无法在滚动视图上设置不可滚动的编辑文本。
这是我的代码
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="#ecedf1">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="@dimen/_200sdp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/_200sdp"
>
<EditText
android:layout_width="@dimen/_280sdp"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/_10sdp"
android:layout_height="@dimen/_40sdp"
android:text="fdgsdfhsfhsfghhsfhsfhf"
android:background="@drawable/customedittext"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/viewPagerIndicator"
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_marginTop="@dimen/_180sdp"
android:gravity="center">
<LinearLayout
android:id="@+id/viewPagerCountDots"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:gravity="center"
android:orientation="horizontal" />
</RelativeLayout>
<com.information.aanjana.aanjanainformation.NonScrollGridView
android:id="@+id/gv_android"
android:layout_width="@dimen/_299sdp"
android:layout_height="match_parent"
android:horizontalSpacing="8dp"
android:layout_centerHorizontal="true"
android:numColumns="2"
android:paddingLeft="@dimen/_4sdp"
android:paddingRight="@dimen/_4sdp"
android:layout_marginTop="@dimen/_220sdp"
android:verticalSpacing="8dp"/>
</RelativeLayout>
</ScrollView>
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_height="match_parent"
android:layout_width="@dimen/_170sdp"
android:layout_gravity="start"
app:menu="@menu/drawer"
/>
</android.support.v4.widget.DrawerLayout>
我想要一个带有导航抽屉的编辑文本,它应该是粘性的,并且不会随着布局的其余部分滚动。我怎样才能实现它。
下面的截图解释了我想要的:
【问题讨论】:
-
嗨,你的 UI 看起来很酷 :)
-
@GKTHEBOSS 谢谢,但你能帮帮我吗? :)
-
你能告诉我你的 searchView 的
id是你想保留在滚动部分之外的吗? -
@himanshu1496 我没有给它 id 但是用这个参数检查edittext android:text="fdgsdfhsfhsfghhsfhsfhf"
-
好的,知道了。很快就会发布我的答案。
标签: android xml android-layout android-scrollview