• ScrollView嵌套Linearlayout显示不全的解决办法


    以为ScrollView只能嵌套一个元素,所以把几个控件都包裹在了一个LinearLayout中了。但是发现底部显示不全,滑动不到最底下。
    代码:

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.v4.widget.NestedScrollView 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:fitsSystemWindows="true"
        android:orientation="vertical"
        android:fillViewport="true"
        tools:context="com.zhb86.nongxin.cn.ui.activity.usedcar.ATUsedCarDetail">
    
        <LinearLayout
            android:layout_marginTop="@dimen/dip_10"
            android:id="@+id/rl"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="@dimen/dip_20"
            android:layout_marginRight="@dimen/dip_20"
            android:orientation="vertical">
    
            <TextView
                android:id="@+id/tv1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="公司介绍"
                android:textColor="#333"
                android:textSize="@dimen/dip_15" />
    
            <TextView
                android:id="@+id/company_introduction"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/dip_10"
                android:minLines="2"
                android:text=""
                android:textColor="#666666"
                android:textSize="@dimen/dip_14" />
    
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="公司文化"
                android:textColor="#333"
                android:textSize="@dimen/dip_15" />
    
            <TextView
                android:id="@+id/company_culture"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/dip_10"
                android:minLines="2"
                android:text=""
                android:textColor="#666666"
                android:textSize="@dimen/dip_14" />
    
            <View
                android:id="@+id/lineone"
                android:layout_width="match_parent"
                android:layout_height="@dimen/common_line"
                android:layout_marginTop="@dimen/dip_10"
                android:background="@color/common_line" />
    
            <TextView
                android:id="@+id/use_time"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/dip_10"
                android:text="公司地址"
                android:textColor="#333"
                android:textSize="@dimen/dip_15" />
    
            <TextView
                android:id="@+id/com_address"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/list_item_selector"
                android:drawableLeft="@drawable/nongjiaddress1x"
                android:maxLines="1"
                android:paddingTop="@dimen/dip_10"
                android:paddingBottom="@dimen/dip_10"
                android:text=""
                android:textColor="#666666"
                android:textSize="@dimen/dip_14" />
    
    
            <View
                android:id="@+id/linethree"
                android:layout_width="match_parent"
                android:layout_height="@dimen/common_line"
                android:background="@color/common_line" />
    
    
            <TextView
                android:id="@+id/customer_information"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/dip_10"
                android:text="公司网站"
                android:textColor="#333"
                android:textSize="@dimen/dip_15" />
    
            <TextView
                android:id="@+id/com_website"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/dip_10"
                android:text=""
                android:textColor="#666666"
                android:textSize="@dimen/dip_14" />
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>
    

    原因是什么呢?
    其实就是LinearLayout中的

    android:layout_marginTop="10dp"
    这样,ScrollView在开始显示的时候就会向下移10dp。解决办法有很多种
    1、把android:layout_marginTop=”10dp”加给ScrllView
    2、给Linearlayout再加上两个属性:

     android:paddingTop="10dp"
     android:paddingBottom="8dp"
  • 相关阅读:
    解决Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.j...
    Docker容器无法启动,里面的配置文件如何修改
    C# lamada find
    【Redis】arm64架构,docker的Redis出现Failed to test the kernel for a bug that could lead to data corruption
    启动Docker容器报错:Error response from daemon: driver failed programming external connectivity
    redis OCI runtime exec failed: exec failed:解决方法
    如何远程访问 Redis
    nanopi r2c上docker安装甜糖
    Net6 EfCore 值对象类型和从属实体类型
    Net6 控制台程序引入Nlog 、Nlog配置文件解读
  • 原文地址:https://www.cnblogs.com/wzqnxd/p/9962667.html
Copyright © 2020-2023  润新知