Android 隐藏LinearLayout
来源:互联网 发布:三星清零软件 编辑:程序博客网 时间:2024/05/18 17:01
有这样的需求,所有的界面上方都有一个标题栏,有些界面需要需要、有些特殊的界面就不需要这个标题栏,需要显示其他的按钮,这个时候就要隐藏掉,切换界面之后就会重新显示,解决方案其实非常简单:
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属性,对显示隐藏进行控制,如下:
@Overrideprotected 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);
}
这样就可以搞定了,欢迎批评指教。
0 0
- Android 隐藏LinearLayout
- android布局LinearLayout的隐藏和显示
- android button控制linearlayout的显示隐藏
- android LinearLayout
- android LinearLayout
- Android -- LinearLayout
- Android LinearLayout
- android linearlayout
- Android LinearLayout
- Android 布局 LinearLayout
- Android 自定义 LinearLayout
- Android之LinearLayout、AbsoluteLayout
- android布局之LinearLayout
- android之布局LinearLayout
- Android 布局 之 LinearLayout
- Android基础(二) LinearLayout
- Android基础(二) LinearLayout
- android linearlayout 平分一行
- Delphi 调用 Java WebService
- java 中类似于goto语句的语法
- 第一篇博客
- 用Xcode6创建xib窗口
- epoll LT和ET区别
- Android 隐藏LinearLayout
- hdu4504基础dp,二维
- Connections could not be acquired from the underlying database!
- 落叶不懂的桑梓心
- 黑马程序员--集合框架和集合操作(List,Queue, Deque,Map)
- Oracle Decode()的使用
- 第十二章 动态内存
- cygwin下面编译proxmark3(at 2015.09.09)
- Hibernate基于Spring模板的DAO基类