我在Android应用程序中遇到问题。当我点击屏幕隐藏工具栏时,它会闪烁。消失的同时显示内容然后消失。
我已经应用了此解决方案:Stackoverflow solution
代码:
content_main.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (toolbar.getVisibility()==View.GONE){
toolbar.setVisibility(View.VISIBLE);
}else{
toolbar.setVisibility(View.GONE);
}
XML:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:rowCount="5"
android:id="@+id/main_content"
android:background="#000000"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="culha.roomdispaly.MainActivity"
android:animateLayoutChanges="true"
tools:showIn="@layout/activity_main">
<TableRow
----------
</TableRow>
</TableLayout>