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 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算