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"
  • 相关阅读:
    ZOJ 3765 Lights (zju March I)伸展树Splay
    UVA 11922 伸展树Splay 第一题
    UVALive 4794 Sharing Chocolate DP
    ZOJ 3757 Alice and Bod 模拟
    UVALive 3983 捡垃圾的机器人 DP
    UVA 10891 SUM游戏 DP
    poj 1328 Radar Installatio【贪心】
    poj 3264 Balanced Lineup【RMQ-ST查询区间最大最小值之差 +模板应用】
    【转】RMQ-ST算法详解
    poj 3083 Children of the Candy Corn 【条件约束dfs搜索 + bfs搜索】【复习搜索题目一定要看这道题目】
  • 原文地址:https://www.cnblogs.com/wzqnxd/p/9962667.html
Copyright © 2011-2022 走看看