android xml .gone,android-setVisibility(GONE)视图变为不可见,但仍占用sp

我认为实际上是一个按钮。 这是其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);

它消失了,但仍然占据空间。 像这样:

ee3eeeab6a9099506f6bd5af6edcdc80.png

此按钮是ListFragment中的标头,它由以下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时占用其他列表项。 如文档中所述。

消失-该视图是不可见的,并且不占用任何空间   布局目的。

关于如何使其不占用空间的任何想法?

谢谢,丹尼斯xx

附言 我的列表视图在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、付费专栏及课程。

余额充值