这是这个android fragment 的 View
下面是 float 按钮部分代码:
<FrameLayout
android:id="@+id/dialpad_floating_action_button_container"
android:background="@drawable/fab_green"
android:layout_width="@dimen/floating_action_button_width"
android:layout_height="@dimen/floating_action_button_height"
android:layout_above="@id/dialpad_floating_action_button_margin_bottom"
android:layout_centerHorizontal="true">
<ImageButton
android:id="@+id/dialpad_floating_action_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/floating_action_button"
android:contentDescription="@string/description_dial_button"
android:src="@drawable/fab_ic_call"/>
</FrameLayout>
但是,Android studio 打印信息:
W/OpenGLRenderer: Incorrectly called buildLayer on View: FrameLayout, destroying layer...
W/OpenGLRenderer: Incorrectly called buildLayer on View: AppCompatImageButton, destroying layer...
而且 float 按钮不显示...
我已经尝试了很多,但仍然不知道它是如何发生的,以及如何检查原因。任何人都可以帮我吗?非常感谢!
最佳答案
最后,我解决了这个问题。 布局xml文件有错误,这是错误的文件内容:
<RelativeLayout
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="6">
<include layout="@layout/dialpad_view"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/dialpad_floating_action_button_container"/>
<!-- "Dialpad chooser" UI, shown only when the user brings up the
Dialer while a call is already in progress.
When this UI is visible, the other Dialer elements
(the textfield/button and the dialpad) are hidden. -->
<ListView android:id="@+id/dialpadChooser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background_dialer_light"
android:visibility="gone" />
<!-- Margin bottom and alignParentBottom don't work well together, so use a Space instead. -->
<Space android:id="@+id/dialpad_floating_action_button_margin_bottom"
android:layout_width="match_parent"
android:layout_height="@dimen/floating_action_button_margin_bottom"
android:layout_alignParentBottom="true" />
<FrameLayout
android:id="@+id/dialpad_floating_action_button_container"
android:background="@drawable/fab_green"
android:layout_width="@dimen/floating_action_button_width"
android:layout_height="@dimen/floating_action_button_height"
android:layout_above="@id/dialpad_floating_action_button_margin_bottom"
android:layout_centerHorizontal="true">
<ImageButton
android:id="@+id/dialpad_floating_action_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/floating_action_button"
android:contentDescription="@string/description_dial_button"
android:src="@drawable/fab_ic_call"/>
</FrameLayout>
</RelativeLayout>
“”标签有一个 id 女巫与下面“”的 id 相同。我意识到也许我把这个 id 复制到了错误的地方。 所以,我只是删除了这个 id, float 按钮显示如我所料;
下面是正确的内容:
<RelativeLayout
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="6">
<include layout="@layout/dialpad_view"
android:layout_height="match_parent"
android:layout_width="match_parent"/>
<!-- "Dialpad chooser" UI, shown only when the user brings up the
Dialer while a call is already in progress.
When this UI is visible, the other Dialer elements
(the textfield/button and the dialpad) are hidden. -->
<ListView android:id="@+id/dialpadChooser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background_dialer_light"
android:visibility="gone" />
<!-- Margin bottom and alignParentBottom don't work well together, so use a Space instead. -->
<Space android:id="@+id/dialpad_floating_action_button_margin_bottom"
android:layout_width="match_parent"
android:layout_height="@dimen/floating_action_button_margin_bottom"
android:layout_alignParentBottom="true" />
<FrameLayout
android:id="@+id/dialpad_floating_action_button_container"
android:background="@drawable/fab_green"
android:layout_width="@dimen/floating_action_button_width"
android:layout_height="@dimen/floating_action_button_height"
android:layout_above="@id/dialpad_floating_action_button_margin_bottom"
android:layout_centerHorizontal="true">
<ImageButton
android:id="@+id/dialpad_floating_action_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/floating_action_button"
android:contentDescription="@string/description_dial_button"
android:src="@drawable/fab_ic_call"/>
</FrameLayout>
</RelativeLayout>
关于android日志信息是 “W/OpenGLRenderer: Incorrectly called buildLayer on View”,这是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40839591/