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" >

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值