zoukankan      html  css  js  c++  java
  • 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"
  • 相关阅读:
    rsyslog 只读取变化的日志
    Invalid component element. Instead of passing a string like 'div', pass React.createElement('div')
    Java 并发之 CountDownLatch、CyclicBarrier 和 Semaphore
    JUC (Java Util Concurrency) 基础内容概述
    浅析Java中CountDownLatch用法
    java 多线程 CountDownLatch用法
    基于Netty的“请求-响应”同步通信机制实现
    响应头location 页面跳转
    8.1 Optimization Overview
    论人不地道,我只佩服TT——北漂18年(68)
  • 原文地址:https://www.cnblogs.com/wzqnxd/p/9962667.html
Copyright © 2011-2022 走看看