Android 隐藏LinearLayout

     有这样的需求,所有的界面上方都有一个标题栏,有些界面需要需要、有些特殊的界面就不需要这个标题栏,需要显示其他的按钮,这个时候就要隐藏掉,切换界面之后就会重新显示,解决方案其实非常简单:

     1.在界面的布局文件xml中,将LinearLayout设置一个id,如下文件:

  <LinearLayout
        android:id="@+id/user_status_bar"
        android:layout_width="fill_parent"
        android:layout_height="25dp"
        android:layout_marginTop="2dp"
        android:background="@color/statebg"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:text="@string/trademargin"
            android:textColor="@color/white"
            android:textSize="12dp" />

        <TextView
            android:id="@+id/price_trademargin"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:textColor="@color/white"
            android:textSize="12dp" />
</LinearLayout>
2.在代码中找到这个布局的id并初始化,之后,使用visiable属性,对显示隐藏进行控制,如下:
@Override
	protected void initStatebarUI() {
		user_status_bar = (LinearLayout) this
				.findViewById(R.id.user_status_bar);if (fragmentKey == IBundleCommData.FRAGMENT_ID_About
				|| fragmentKey == IBundleCommData.FRAGMENT_ID_Message
				|| fragmentKey == IBundleCommData.FRAGMENT_ID_FOREIGN_NEWS
				|| fragmentKey == IBundleCommData.FRAGMENT_ID_SelectInstrumentFragment
				|| fragmentKey == IBundleCommData.FRAGMENT_ID_FOREIGN_NEWSCOMMENT) {
			hideUserStatus(View.GONE);

		} else {
			hideUserStatus(View.VISIBLE);

}

 

      这样就可以搞定了,欢迎批评指教。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值