android Scrollview里的内容不停留在顶部的问题
2016-10-20 14:50
267 查看
先说明一下:任何一个页面都应该按照布局的先后顺序来显示,我这出现的问题就是,Scrollview里面嵌套Listview的头布局一进来看不见了,直接被Listview把焦点给抢了。最先显示的是Listview的item部分。直接上图
解决代码在父布局里设置2个属性
解决代码在父布局里设置2个属性
android:focusable="true" android:focusableInTouchMode="true"
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.kyhh.youngworld.main.classification.activity.BrandListingActivity"> <include layout="@layout/system_titlebar_layouot" /> <com.kyhh.youngworld.widget.StickScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <!--这是包裹Listview头布局的父布局,在这里添加属性-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true" android:focusableInTouchMode="true">
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/length_200"
android:src="@color/textgray2" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/brandlist_tv_attention"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_pressed"
android:clickable="true"
android:padding="5dp"
android:text="关注"
android:textSize="18sp" />
<TextView
android:id="@+id/brandlist_tv_attentioncount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="关注人数" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/btn_pressed"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="10dp"
android:tag="sticky">
<TextView
android:id="@+id/brandlist_tv_integration"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="12dp"
android:background="@drawable/btn_pressed"
android:gravity="center"
android:padding="5dp"
android:text="综合排序" />
<TextView
android:id="@+id/brandlist_tv_sales"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="@drawable/btn_pressed"
android:gravity="center"
android:padding="5dp"
android:text="销量" />
<TextView
android:id="@+id/brandlist_tv_price"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_marginRight="12dp"
android:background="@drawable/btn_pressed"
android:gravity="center"
android:padding="5dp"
android:text="价格" />
</RelativeLayout>
<com.kyhh.youngworld.widget.NoScrollListview
android:id="@+id/brandlist_xrc_goodslist"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.kyhh.youngworld.widget.NoScrollListview>
</LinearLayout>
</com.kyhh.youngworld.widget.StickScrollView>
</LinearLayout>
相关文章推荐
- android scrollview listview 嵌套, 显示时总是显示listview内容,没有显示到activity顶部问题
- Android Scrollview不能定位到顶部的问题?
- Android ScrollView嵌套Viewpager嵌套ListView切换时到顶部或位置改变问题解决
- Android 打造顶部停留控件,可用于所有可滚动的控件(ScrollView,ListView)
- Android问题:ScrollView默认位置不是最顶部最全解决方案
- Android 关于在ScrollView中加上一个ListView,ListView内容显示不完全(总是显示第一项)的问题的两种简单的解决方案
- Android 解决ScrollView下嵌套ListView进页面不在顶部的问题
- 解决ScrollView嵌套ListView、GridView默认不停留顶部的问题
- 【Android - 问题解决】之ScrollView嵌套ListView时总是自动滑动到ListView顶部的问题
- Android问题:ScrollView默认位置不是最顶部最全解决方案
- Android ActionBar的Overlay模式如何不遮盖顶部内容的问题
- Android 关于在ScrollView中加上一个ListView,ListView内容显示不完全(总是显示第一项)的问题的两种简单的解决方案
- Android中ScrollView和ListView嵌套使用时,进入界面不是从起始位置也即是不是从顶部显示问题
- [Android]取得Dialog中EditText的内容问题
- Android中ScrollView与ListView共用问题的解决方案
- android 关于 ScrollView嵌套GridView,ListView 显示和滑动的问题
- (转)Android中ScrollView与ListView共用问题的解决方案
- Android 解决ListView 和 ScrollView 共存冲突的问题
- [Android实例] Android 解决ListView 和 ScrollView 共存冲突的问题
- Android中ScrollView导致listView无法拖动的问题