- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
它是如何工作的?我有如下布局:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/search_form_fragment"
android:name="FragmentClass"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<fragment
android:id="@+id/result_list_fragment"
android:name="FragmentClass"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
</LinearLayout>
请注意第二个 fragment 有 android:visibility="gone"
并且实际上它在屏幕上不可见。但是这段代码:
boolean bothVisible = firstFrag.isVisible() && secondFrag.isVisible();
返回true
,这出乎我的意料。我想知道使用 android:visibility
是否正确,因为我在文档中找不到任何关于它的信息。
最佳答案
根据 Fragment source , isVisible
定义为:
final public boolean isVisible() {
return isAdded() && !isHidden() && mView != null
&& mView.getWindowToken() != null &&
mView.getVisibility() == View.VISIBLE;
}
即,它附加到 Activity,未隐藏(通过 FragmentTransaction.hide ), View 被放大, View 附加到窗口, fragment 的内部 View 是 View.VISIBLE
。
我认为问题是为了膨胀您的 fragment ,系统创建了一个布局来保存 fragment 的 View 。这是您设置为 View.GONE
的 View ,而不是 Fragment 创建的内部 View 。
我可能会建议将您的条件更改为:
findViewById(R.id.result_list_fragment).getVisibility() == View.VISIBLE
关于android - fragment 机器人 :visibility in xml layout definition,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16466868/
我制作了一个 DIV 和 visibility: hidden 并附加了一个 ::before 这个 DIV 的伪元素 visibility : 可见。这在 Firefox、Chrome 和 Safa
我正在使用 jquery 可见选择器来检查子元素是否可见。但令人惊讶的是 .is("visible") 和 .is(":visible") 在使用 css Visibility:hidden 时显示不
我有这个代码 #checkboxDIV { visibility: hidden; } #itemcard:hover #checkboxDIV {
我有一个用 ul 创建的菜单/li列出。 为了创造一个不错的效果,我有以下 css: #menu ul { /* ... */ visibility:hidden; /* ..
我想要的是,当我点击 Dashboard Button 时,它会像 SlidingDrawer 一样打开,打开后再次点击它会关闭。我使用这个自定义抽屉是因为 SlidingDrawer 已弃用。 现在
如何使用 jQuery 只选择可见元素? jQuery 选择器 :visible 和 :hidden 只尊重 display:none 作为真的隐藏?不是可见性:隐藏或可见性:可见。 我知道它们在技术
为什么我的 $('#myDiv').css('visibility', 'visible'); 不起作用? $('#clickdiv').click(function() { alert($(
在 $(document).ready 函数中通过 JavaScript 将子容器设置为 visibility: visible 时,我遇到了一个奇怪的问题。 问题是: 我有一个父元素,它有 boot
在 jQuery 中: e.is(':visible'); 检查元素是否显示。 jQuery 中是否有一个函数可以检查元素是否具有隐藏或可见属性可见性? 现在我必须自己实现这个功能。但我想使用 jQu
我在 mvc 中使用一个帖子表单,在帖子中我想显示一个隐藏的 div(惊喜)。 我正在使用 js/jquery 来显示 div,它可以在所有浏览器中工作,除了 mac 上的 safari :( 我现在
我似乎无法获得我的 jquery {{NotificationNavDot}} 功能正常工作! 在下面找到帮助文件: {{NotificationNavDot}} 在下面找到我的帮助
WPF 中的 Visibility.Collapsed 和 Visibility.Hidden 有什么区别? 最佳答案 不同之处在于,Visibility.Hidden隐藏了控件,但保留了它在布局中占
我有一个 if 语句来检查我的 div 下面是否没有任何可见内容,如果是,我会隐藏子元素的同级元素。 var $remainingprojects = $searchproject.s
这是我的菜单模型 HTML Menu 1 (overflow:hidden) Item 1 submenu 1 submen
编辑 3 实际上,我根本不需要弄乱可见性/不透明度...所以我删除了那些行(如编辑 2 所示)...添加了动画 -播放状态:暂停/运行.... 得到了我想要的效果... 编辑 2:感谢 Gineto
在我的应用程序中有一个广告 WebView ,它在 Activity 开始时调用一个 url。一切都很好,除了一件小事,它更像是一个可见性问题......所以问题是,当我开始 Activity 时,我
根据 the "visible" binding documentation , 如果 visible 的值为 false,Knockout 使用 display: none 隐藏元素。我怎样才能让它
* { margin: 0; padding: 0; border: 0; } .navBar { background-color: #2A2A2A; min-width: 10
android 布局使用 layout_weight。我的目标是所有组件的 1/3,但有时页脚实际上设置为消失,然后可见。从 gone 设置为 visible 时,权重计算如何工作?我没有看到具有 1
我有两个单选按钮,两个文本框和一个按钮。 当我点击第一个按钮时,应该只会出现一个文本框,当我点击第二个按钮时,应该会出现两个文本框。 但我想使用 visibility:hidden|visible 属
我是一名优秀的程序员,十分优秀!