您好,欢迎来到暴趣科技网。
搜索
您的当前位置:首页android gone了高度还在,android – setVisibility(GONE)视图变为不可见,但仍占用空间

android gone了高度还在,android – setVisibility(GONE)视图变为不可见,但仍占用空间

来源:暴趣科技网

我有一个视图,实际上是一个按钮。这里是它的XML布局(add_new.xml)

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="horizontal">

android:id="@+id/buttonNew"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/bText"

android:onClick="addNew"/>

当我把它的可见性设置为GONE这样

v = getActivity().getLayoutInflater().inflate(R.layout.add_new, null);

v.setVisibility(View.GONE);

它消失但仍占据空间。喜欢这个:

此按钮是ListView中的一个标题,它由此xml定义:

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/porno" >

android:id="@+id/icon"

android:layout_width="30dp"

android:layout_height="40dp"

android:layout_marginLeft="4dp"

android:layout_marginRight="10dp"

android:layout_marginTop="4dp"

android:src="@drawable/ic_launcher">

android:id="@+id/label"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@+id/label"

android:textSize="20dp" >

我不希望它的可见性设置为GONE时占用额外的列表项。正如文档中所述。

GONE – This view is invisible, and it doesn’t take any space for

layout purposes.

任何想法如何使它不占用空间?

谢谢,

丹尼斯xx

P.S。我的listview是在FoldersFragment ListFragment里面,这里是我的MainActivity的xml,其中FoldersFragment呈现

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="horizontal" >

android:id="@+id/foldersFragment"

android:layout_width="200dip"

android:layout_height="match_parent"

class="com.example.fragments.FoldersFragment" >

android:id="@+id/detailFragment"

android:layout_width="match_parent"

android:layout_height="match_parent"

class="com.example.fragments.DetailFragment" >

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- baoquwan.com 版权所有 湘ICP备2024080961号-7

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务