qq_33066259 2018-04-24 04:04 采纳率: 100%
浏览 1092
已采纳

Android 线性布局ScrollView嵌套以及TextView设置background的小问题

ScrollView 部分布局
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/part_line"
android:layout_above="@id/pay_go"

    >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingTop="5dp"
        android:orientation="vertical"
        android:id="@+id/pay_main_info">
        <include layout="@layout/add_address"
            android:id="@+id/address_desc"/>
        <View
            android:layout_width="match_parent"
            android:layout_height="1px"
            android:layout_marginBottom="5dip"
            android:layout_marginTop="5dip"
            />
        <include layout="@layout/pay_other_info"
            android:id="@+id/pay_other_info"/>
        <View
            android:layout_width="match_parent"
            android:layout_height="5px"
            android:layout_marginBottom="5dip"
            android:layout_marginTop="5dip"
            />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="桃李园"
            android:textSize="25dp"
            android:layout_marginLeft="20dp"
            android:textColor="@color/black"
            android:id="@+id/pay_order_form_canteen_name"/>
        <View
            android:layout_width="match_parent"
            android:layout_height="5px"
            android:layout_marginBottom="5dip"
            android:layout_marginTop="5dip"

            />
        <ListView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:id="@+id/pay_order_form_foodlist">

            </ListView>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="添加备注"
            android:drawableRight="@mipmap/more"
            android:textSize="20dp"
            android:layout_marginLeft="20dp"
            android:textColor="@color/black"
            android:layout_marginRight="20dp"
            android:clickable="true"
            android:id="@+id/pay_order_form_add_remakes"/>



    </LinearLayout>
</ScrollView>


    布局效果图:
    ![图片说明](https://img-ask.csdn.net/upload/201804/24/1524541534_568444.png)

    实际效果图:
    ![图片说明](https://img-ask.csdn.net/upload/201804/24/1524541656_487597.png)

    期望效果:
      实现类似于饿了么的那种界面,把listview的界面填充出去,如图下:

![图片说明](https://img-ask.csdn.net/upload/201804/24/1524542251_73813.png)

        TextView的设置background的bug:

        TextView代码:
        <TextView
        android:id="@+id/add_address_btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
       android:background="@drawable/text_bg"
        android:gravity="center"
        android:paddingBottom="20dip"
        android:paddingLeft="15dip"
        android:paddingRight="15dip"
        android:paddingTop="20dip"
        android:text="+添加收货地址"
        android:textColor="@color/theme_blue_two"
        android:textSize="30sp"
        android:layout_centerHorizontal="true"
       />
                效果:
                ![图片说明](https://img-ask.csdn.net/upload/201804/24/1524542466_880111.png)
                background的效果并没有运用上去,附其他可用的TextView的效果,如图下:
                ![图片说明](https://img-ask.csdn.net/upload/201804/24/1524542599_493676.png)
  • 写回答

3条回答

  • nades 2018-04-24 08:01
    关注

    你这属于滑动空间嵌套滑动空间问题 需要重写listview 要不然就会出现显示不全的问题 还有滑动冲突问题
    自定义一个listview 继承 listview 重写onmeasure 方法 重新测量高度

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int measureSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);

        super.onMeasure(widthMeasureSpec, measureSpec);
    
    }
    

    很简单 重写这一个方法就可以 然后再xml 文件中引用就好了 你试一下

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误