scrollView嵌套webview+listview listview显示不全 上拉listview加载更多

最近项目需要,用到scrollView嵌套webview+listview来做展示,遇到了一些坑,记录下来。

先上效果图

直接上代码

布局文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:background="#f8f8f8"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/rl_post_dateils_top"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/top_bg"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/iv_post_details_back"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="16dp"
            android:layout_marginTop="29dp"
            android:src="@drawable/forums_back" />

        <TextView
            android:id="@+id/tv_post_details_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="120dp"
            android:layout_marginTop="29dp"
            android:text="正文"
            android:textColor="@android:color/white"
            android:textSize="18sp" />
    </LinearLayout>
<-- AbPullToRefreshView 上拉加载更多的控件 -->
    <com.ab.view.pullview.AbPullToRefreshView
        android:id="@+id/reply_pull_refresh_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/view_footer"
        android:layout_below="@+id/rl_post_dateils_top" >
        <include
            android:id="@+id/scroll_view_content"
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            layout="@layout/layout_post_details_content"
            android:background="@android:color/white" />
    </com.ab.view.pullview.AbPullToRefreshView>

    <include
        android:id="@+id/view_footer"
        layout="@layout/layout_post_details_reply" />

</RelativeLayout>

layout_post_details_content布局
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/sc_view"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_marginBottom="40dp"
    android:background="#f8f8f8"
    android:orientation="vertical"
    android:scrollbars="none" >


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#f8f8f8"
            android:orientation="vertical" >


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="fill_parent"
                android:layout_marginLeft="8dp"
                android:layout_marginTop="8dp"
                android:orientation="horizontal" >


                <com.example.netprobe.view.CircleImageView
                    android:id="@+id/iv_details_creator"
                    android:layout_width="20dp"
                    android:layout_height="20dp" >
                </com.example.netprobe.view.CircleImageView>


                <TextView
                    android:id="@+id/tv_post_details_creator"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="6dp"
                    android:text="用户名"
                    android:textColor="#989898" />


                <TextView
                    android:id="@+id/tv_post_details_createtime"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="140dp"
                    android:text="时间"
                    android:textColor="#989898" />
            </LinearLayout>


            <TextView
                android:id="@+id/tv_post_details_Title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="4dp"
                android:layout_marginLeft="8dp"
                android:layout_marginTop="6dp"
                android:maxLines="1"
                android:text="标题"
                android:textSize="18sp"
                android:textStyle="bold" />
        </LinearLayout>


        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#e5e5e5" />


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:focusable="true"
            android:focusableInTouchMode="true" >


            <WebView
                android:id="@+id/wv_post_details_content"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
        </LinearLayout>


        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#e5e5e5" />


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:focusable="true"
            android:focusableInTouchMode="true" >




                <com.example.netprobe.view.MyListView
                    android:id="@+id/lv_postreply_list"
                    android:layout_width="match_parent"
                    android:layout_height="fill_parent"
                    android:cacheColorHint="#00000000"
                    android:fadingEdge="none"
                    android:focusable="false"
                    android:listSelector="@android:color/transparent"
                    android:soundEffectsEnabled="false" >
                </com.example.netprobe.view.MyListView>
      
        </LinearLayout>
    </LinearLayout>


</ScrollView>

view_footer布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="42dp"
    android:layout_alignParentBottom="true"
    android:background="#efeeee"
    android:orientation="horizontal" >


    <EditText
        android:id="@+id/tv_postreply"
        android:layout_width="240dp"
        android:layout_height="30dp"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="16dp"
        android:background="@drawable/atom_edit_bg" />


    <Button
        android:id="@+id/btn_send_postreply"
        android:layout_width="70dp"
        android:layout_height="30dp"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="18dp"
        android:layout_marginRight="8dp"
        android:background="@drawable/btn_blue_bg"
        android:gravity="center"
        android:text="评论" />


</LinearLayout>



webview 和listview的上一级要加上
 android:focusable="true"
 android:focusableInTouchMode="true"
listview 最好是自己自定义一个  item的布局最好不要用RelativeLayout
到这个地方listview应该就可以完全显示了

还有状态栏我这里设置了透明
 if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
            // 透明状态栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        } 
在清单文件里的activity里加上
android:windowSoftInputMode="stateHidden|adjustResize"

并在setContentView(R.layout.*******);后加上AndroidBug5497Workaround.assistActivity(this);软键盘在全屏下的布局计算
到这里就实现了这个效果。

实现这个效果搜了很多,看了很多同样的博客,但很多都是没用的 例如 android:fitsSystemWindows="true"什么的 还有说其他的。但还是感谢大家的无私奉献。希望这篇文章对有需要的人会有帮助,最重要的是自己要多动手。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值