setVisibility(View.INVISIBLE) 在 MapFragment 中不起作用
setVisibility(View.INVISIBLE) not working in MapFragment
我有一个具有展开和折叠功能的地图片段。因此,当我展开地图时,我想隐藏 LinearLayout,当我折叠时,我想显示该布局。
但是 setVisibility(View.INVISIBLE);
不工作。当我调试应用程序时,我可以看到编译器正在读取该行,但仍然无法正常工作。
这是我的 XML 文件
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/main_fragment_constraint_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
tools:context=".MainActivity"
tools:visibility="visible">
<fragment
android:id="@+id/map"
class="com.google.android.gms.maps.MapFragment"
android:layout_width="590dp"
android:layout_height="550dp"
android:layout_marginStart="24dp"
android:layout_marginTop="110dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:context="com.korechi.roamioapp.MainActivity"
tools:layout="@layout/activity_main_left_hand" />
<org.ros.android.view.RosImageView
android:id="@+id/cameraView"
android:layout_width="590dp"
android:layout_height="550dp"
android:layout_marginStart="24dp"
android:layout_marginTop="100dp"
android:background="@color/black"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:context="com.korechi.seekerapp.MainActivity"
tools:layout="@layout/activity_main_left_hand" />
<Button
android:id="@+id/viewToggleBtn"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:alpha="0.8"
android:background="@drawable/ic_sharp_arrow"
app:layout_constraintStart_toEndOf="@id/mapSnapBtn"
app:layout_constraintTop_toTopOf="@id/mapSnapBtn" />
<ImageView
android:id="@+id/imageView"
android:layout_width="590dp"
android:layout_height="520dp"
android:layout_marginStart="24dp"
android:layout_marginTop="100dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:context="com.korechi.roamioapp.MainActivity"
tools:layout="@layout/activity_main_left_hand" />
<org.ros.android.view.RosTextView
android:id="@+id/speedROS"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="@+id/totalAreaRos"
app:layout_constraintTop_toTopOf="@+id/totalAreaRos" />
<org.ros.android.view.RosTextView
android:id="@+id/rtkStat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="@color/black"
app:layout_constraintStart_toStartOf="@+id/rtkLED"
app:layout_constraintTop_toBottomOf="@+id/rtkLED" />
<org.ros.android.view.RosTextView
android:id="@+id/lidarStat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="@color/black"
app:layout_constraintStart_toStartOf="@+id/lidarLED"
app:layout_constraintTop_toBottomOf="@+id/lidarLED" />
<org.ros.android.view.RosTextView
android:id="@+id/spreaderStat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="@color/black"
app:layout_constraintStart_toStartOf="@+id/spreaderLED"
app:layout_constraintTop_toBottomOf="@+id/spreaderLED" />
<Button
android:id="@+id/rtkLED"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:background="@drawable/grey_rounded_button"
android:text="RTK"
app:layout_constraintEnd_toStartOf="@+id/lidarLED"
app:layout_constraintTop_toTopOf="@+id/lidarLED" />
<Button
android:id="@+id/lidarLED"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="50dp"
android:background="@drawable/grey_rounded_button"
android:text="LiDAR"
app:layout_constraintEnd_toStartOf="@+id/roamIOLogo"
app:layout_constraintTop_toTopOf="@+id/roamIOLogo" />
<LinearLayout
android:id="@+id/linearLayoutRoamIOLatLong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="@id/cameraView"
app:layout_constraintTop_toBottomOf="@+id/cameraView">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textLatitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="22dp"
android:layout_marginBottom="15dp"
android:text="Latitude"
android:textColor="@android:color/black"
android:textSize="18sp" />
<org.ros.android.view.RosTextView
android:id="@+id/latitudeTextView"
android:layout_width="150dp"
android:layout_height="25dp"
android:layout_marginStart="16dp"
android:background="@drawable/textviewshape"
android:textAlignment="center"
android:textColor="@android:color/black"
android:textSize="18sp"
app:layout_constraintStart_toEndOf="@+id/textLatitude"
app:layout_constraintTop_toTopOf="@+id/textLatitude" />
<TextView
android:id="@+id/textLongitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:text="Longitude"
android:textColor="@android:color/black"
android:textSize="18sp"
app:layout_constraintStart_toEndOf="@+id/latitudeTextView"
app:layout_constraintTop_toTopOf="@+id/latitudeTextView" />
<org.ros.android.view.RosTextView
android:id="@+id/longitudeTextView"
android:layout_width="150dp"
android:layout_height="25dp"
android:layout_marginStart="16dp"
android:background="@drawable/textviewshape"
android:textAlignment="center"
android:textColor="@android:color/black"
android:textSize="18sp"
app:layout_constraintStart_toEndOf="@+id/textLongitude"
app:layout_constraintTop_toTopOf="@+id/textLongitude" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textHeading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="22dp"
android:text="Heading"
android:textColor="@android:color/black"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="@+id/textLongitude"
app:layout_constraintTop_toBottomOf="@+id/textLongitude" />
<org.ros.android.view.RosTextView
android:id="@+id/headingTextView"
android:layout_width="150dp"
android:layout_height="25dp"
android:layout_marginStart="16dp"
android:background="@drawable/textviewshape"
android:textAlignment="center"
android:textColor="@android:color/black"
android:textSize="18sp"
app:layout_constraintStart_toEndOf="@+id/textHeading"
app:layout_constraintTop_toTopOf="@+id/textHeading" />
<TextView
android:id="@+id/textAltitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="26dp"
android:text="Altitude"
android:textColor="@android:color/black"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="@+id/textLatitude"
app:layout_constraintTop_toBottomOf="@+id/textLatitude" />
<org.ros.android.view.RosTextView
android:id="@+id/altitudeTextView"
android:layout_width="150dp"
android:layout_height="25dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="17dp"
android:background="@drawable/textviewshape"
android:textAlignment="center"
android:textColor="@android:color/black"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/timeTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="480dp"
android:text="Time"
android:textColor="@android:color/black"
android:textSize="30sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/roamIOLogo" />
<org.ros.android.view.RosTextView
android:id="@+id/pointsHelperTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="@+id/linearLayout"
app:layout_constraintTop_toTopOf="@+id/linearLayout" />
<org.ros.android.view.RosTextView
android:id="@+id/rapgPointsTextView"
android:layout_width="wrap_content"
android:layout_height="13dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toStartOf="@+id/pointsHelperTextView"
app:layout_constraintTop_toTopOf="@+id/pointsHelperTextView" />
<org.ros.android.view.RosTextView
android:id="@+id/waypointsCoveredTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toStartOf="@+id/rapgPointsTextView"
app:layout_constraintTop_toTopOf="@id/linearLayout" />
<org.ros.android.view.RosTextView
android:id="@+id/totalDistanceRos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toStartOf="@id/rapgPointsTextView"
app:layout_constraintTop_toTopOf="@id/linearLayout" />
<org.ros.android.view.RosTextView
android:id="@+id/totalAreaRos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toStartOf="@id/totalDistanceRos"
app:layout_constraintTop_toTopOf="@id/linearLayout" />
<Button
android:id="@+id/batteryInfoBtn"
android:layout_width="130dp"
android:layout_height="40dp"
android:layout_marginStart="20dp"
android:layout_marginTop="4dp"
android:background="@drawable/battery"
android:text="Battery %"
android:textAlignment="center"
android:textSize="18sp"
app:layout_constraintStart_toEndOf="@id/settingsBtn"
app:layout_constraintTop_toTopOf="@id/settingsBtn" />
<org.ros.android.view.RosTextView
android:id="@+id/programStatusTextView"
android:layout_width="590dp"
android:layout_height="28dp"
android:layout_marginBottom="6dp"
android:background="@drawable/textviewshape"
android:textAlignment="center"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/map"
app:layout_constraintStart_toStartOf="@+id/map" />
<ProgressBar
android:id="@+id/batteryIndicaterBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="240dp"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="1dp"
android:visibility="visible"
app:layout_constraintStart_toEndOf="@+id/batteryInfoBtn"
app:layout_constraintTop_toTopOf="@+id/batteryInfoBtn" />
<org.ros.android.view.RosTextView
android:id="@+id/batteryPercentageTxtView"
android:layout_width="240dp"
android:layout_height="40dp"
android:layout_marginTop="6dp"
android:textAlignment="center"
android:textColor="@android:color/black"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="@+id/batteryIndicaterBar"
app:layout_constraintTop_toTopOf="@+id/batteryIndicaterBar" />
<ImageView
android:id="@+id/roamIOLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:src="@drawable/romaio_logo"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/EStopBtn"
android:layout_width="140dp"
android:layout_height="140dp"
android:layout_marginEnd="50dp"
android:layout_marginBottom="50dp"
android:background="@drawable/e_stop"
android:text="@string/estop"
android:textColor="@android:color/white"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@id/left_main_layout"
app:layout_constraintEnd_toStartOf="@id/left_main_layout" />
<Button
android:id="@+id/settingsBtn"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_marginStart="20dp"
android:layout_marginTop="16dp"
android:background="@drawable/gear"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/expandBtn"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/expand"
android:textAlignment="textStart"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="@id/left_main_layout"
app:layout_constraintTop_toTopOf="@id/left_main_layout" />
<Button
android:id="@+id/magnetBtn"
android:layout_width="60dp"
android:layout_height="60dp"
android:background="@drawable/ic_magnet_01"
android:textAlignment="textStart"
app:layout_constraintStart_toStartOf="@id/left_main_layout"
app:layout_constraintTop_toTopOf="@id/left_main_layout" />
<Button
android:id="@+id/clearMapBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginEnd="56dp"
android:alpha="0.80"
android:text="Clear"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="@id/map"
app:layout_constraintTop_toTopOf="@id/map" />
<Button
android:id="@+id/expandMapBtn"
android:layout_width="55dp"
android:layout_height="50dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="8dp"
android:background="@drawable/expand_map"
android:visibility="visible"
app:layout_constraintEnd_toStartOf="@id/clearMapBtn"
app:layout_constraintRight_toLeftOf="@+id/clearMapBtn"
app:layout_constraintTop_toTopOf="@id/map" />
<Button
android:id="@+id/mapSnapBtn"
android:layout_width="55dp"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp"
android:alpha="0.80"
android:background="@drawable/camera_icon"
app:layout_constraintStart_toStartOf="@id/map"
app:layout_constraintTop_toTopOf="@id/map" />
<Button
android:id="@+id/saveMapBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginTop="0dp"
android:alpha="0.80"
android:text="Save Heat Map"
app:layout_constraintStart_toEndOf="@+id/viewToggleBtn"
app:layout_constraintTop_toTopOf="@+id/viewToggleBtn" />
<Button
android:id="@+id/spreaderLED"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:background="@drawable/grey_rounded_button"
android:text="Spreader"
app:layout_constraintEnd_toStartOf="@id/rtkLED"
app:layout_constraintTop_toTopOf="@id/rtkLED" />
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:layout_editor_absoluteX="640dp"
tools:layout_editor_absoluteY="1dp">
<FrameLayout
android:id="@+id/left_frag_holder"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:id="@+id/left_main_layout"
android:layout_width="399dp"
android:layout_height="396dp"
android:baselineAligned="false"
android:orientation="horizontal"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="@+id/linearLayout"
app:layout_constraintEnd_toEndOf="@+id/linearLayout">
<LinearLayout
android:id="@+id/left_side_layout"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="vertical">
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
<com.korechi.roamioapp.Views.VirtualJoystickView
android:id="@+id/left_virtual_joystick"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_gravity="center"
android:layout_weight="4"
android:adjustViewBounds="true" />
<View
android:layout_width="0dip"
android:layout_height="0dip"
android:layout_weight="0" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
这是我调用 setVisibility()
函数的代码
case R.id.expandMapBtn:
mVib.vibrate(50);
storageAccess.logMessage("Expand button click");
expandMapBtn.startAnimation(myAnim);
constraintMap.clone(constraintLayout);
constraintMap.clear(R.id.map, ConstraintSet.START);
constraintMap.clear(R.id.map, ConstraintSet.TOP);
constraintMap.applyTo(constraintLayout);
constraintMap.connect(R.id.map, ConstraintSet.START, R.id.main_fragment_constraint_layout, ConstraintSet.START);
constraintMap.connect(R.id.map, ConstraintSet.TOP, R.id.main_fragment_constraint_layout, ConstraintSet.TOP);
System.out.println(isViewExpanded());
linearLayoutRoamIOLatLong = findViewById(R.id.linearLayoutRoamIOLatLong);
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int height = displayMetrics.heightPixels;
int width = displayMetrics.widthPixels;
if (!isMapExpanded()) {
constraintMap.constrainHeight(R.id.map, height);
constraintMap.constrainWidth(R.id.map, width);
constraintMap.connect(R.id.map, ConstraintSet.START, R.id.main_fragment_constraint_layout, ConstraintSet.START);
constraintMap.connect(R.id.map, ConstraintSet.TOP, R.id.main_fragment_constraint_layout, ConstraintSet.TOP);
constraintMap.setMargin(R.id.map, ConstraintSet.START, 0);
constraintMap.setMargin(R.id.map, ConstraintSet.TOP, 150);
constraintMap.connect(R.id.longitudeTextView, ConstraintSet.INVISIBLE, R.id.main_fragment_constraint_layout, ConstraintSet.TOP);
linearLayoutRoamIOLatLong.setVisibility(View.INVISIBLE);
leftFragHolder.setVisibility(View.INVISIBLE);
storageAccess.logMessage("Map Layout Expanded");
setMapExpanded(true);
System.out.println("Map Fragment Expanded");
} else {
constraintMap.constrainHeight(R.id.map, 850);
constraintMap.constrainWidth(R.id.map, 890);
constraintMap.connect(R.id.map, ConstraintSet.START, R.id.main_fragment_constraint_layout, ConstraintSet.START);
constraintMap.connect(R.id.map, ConstraintSet.TOP, R.id.main_fragment_constraint_layout, ConstraintSet.TOP);
constraintMap.setMargin(R.id.map, ConstraintSet.START, 24);
constraintMap.setMargin(R.id.map, ConstraintSet.TOP, 150);
linearLayoutRoamIOLatLong.setVisibility(View.VISIBLE);
leftFragHolder.setVisibility(View.VISIBLE);
storageAccess.logMessage("Map Layout Collapse");
setMapExpanded(false);
System.out.println("Map Fragment Collapse");
}
constraintMap.applyTo(constraintLayout);
break;
我像这样使用 LayoutParams 来水平隐藏一个接一个的元素:
LinearLayout.LayoutParams params_visible = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layoutToBeVisible.setLayoutParams(params_visible);
LinearLayout.LayoutParams params_invisible = new LinearLayout.LayoutParams(
0, LinearLayout.LayoutParams.WRAP_CONTENT);
layoutToBeInvisible.setLayoutParams(params_invisible);
LayoutParams第一个参数是宽度,第二个参数是高度。
在 FrameLayout
中覆盖您的片段 xml 部分,然后在 Java 代码中对该 FrameLayout 对象调用 setVisibility()。
更新:
为了隐藏存储在您的视图组下的视图,即线性布局,将您的线性布局与 Framelayout 作为父级包围起来。
我找到了解决方法。我正在将 Linearlayout 约束设置到屏幕外,因此它不再可见,并以编程方式返回设置默认约束。
我所做的是在单击展开按钮时以编程方式将设置约束添加到 app:layout_constraintBottom_toTopOf="parent"
。(展开时)
然后在折叠时以编程方式设置默认约束和边距。
app:layout_constraintBottom_toBottomOf="@+id/linearLayout"
app:layout_constraintEnd_toEndOf="@+id/linearLayout"
这是解决方案的代码
case R.id.expandMapBtn:
mVib.vibrate(50);
storageAccess.logMessage("Expand button click");
expandMapBtn.startAnimation(myAnim);
constraintMap.clone(constraintLayout);
constraintMap.clear(R.id.map, ConstraintSet.START);
constraintMap.clear(R.id.map, ConstraintSet.TOP);
constraintMap.applyTo(constraintLayout);
constraintMap.connect(R.id.map, ConstraintSet.START, R.id.main_fragment_constraint_layout, ConstraintSet.START);
constraintMap.connect(R.id.map, ConstraintSet.TOP, R.id.main_fragment_constraint_layout, ConstraintSet.TOP);
constraintMap.setAlpha(R.id.linearLayoutRoamIOLatLong,100);
System.out.println(isViewExpanded());
linearLayoutRoamIOLatLong = findViewById(R.id.linearLayoutRoamIOLatLong);
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int height = displayMetrics.heightPixels;
int width = displayMetrics.widthPixels;
if (!isMapExpanded()) {
constraintMap.constrainHeight(R.id.map, height);
constraintMap.constrainWidth(R.id.map, width);
constraintMap.connect(R.id.map, ConstraintSet.START, R.id.main_fragment_constraint_layout, ConstraintSet.START);
constraintMap.connect(R.id.map, ConstraintSet.TOP, R.id.main_fragment_constraint_layout, ConstraintSet.TOP);
constraintMap.setMargin(R.id.map, ConstraintSet.START, 0);
constraintMap.setMargin(R.id.map, ConstraintSet.TOP, 150);
constraintMap.connect(R.id.linearLayoutRoamIOLatLong, ConstraintSet.BOTTOM, R.id.main_fragment_constraint_layout, ConstraintSet.TOP);
linearLayoutRoamIOLatLong.setVisibility(View.INVISIBLE);
leftFragHolder.setVisibility(View.INVISIBLE);
storageAccess.logMessage("Map Layout Expanded");
setMapExpanded(true);
System.out.println("Map Fragment Expanded");
} else {
constraintMap.constrainHeight(R.id.map, 850);
constraintMap.constrainWidth(R.id.map, 890);
constraintMap.connect(R.id.map, ConstraintSet.START, R.id.main_fragment_constraint_layout, ConstraintSet.START);
constraintMap.connect(R.id.map, ConstraintSet.TOP, R.id.main_fragment_constraint_layout, ConstraintSet.TOP);
constraintMap.connect(R.id.linearLayoutRoamIOLatLong, ConstraintSet.LEFT, R.id.main_fragment_constraint_layout, ConstraintSet.LEFT);
constraintMap.connect(R.id.linearLayoutRoamIOLatLong, ConstraintSet.BOTTOM, R.id.main_fragment_constraint_layout, ConstraintSet.BOTTOM);
constraintMap.setMargin(R.id.map, ConstraintSet.START, 24);
constraintMap.setMargin(R.id.map, ConstraintSet.TOP, 150);
// constraintMap.setMargin(R.id.linearLayoutRoamIOLatLong, ConstraintSet.TOP, 75);
constraintMap.setMargin(R.id.linearLayoutRoamIOLatLong, ConstraintSet.BOTTOM, 25);
constraintMap.setMargin(R.id.linearLayoutRoamIOLatLong, ConstraintSet.START, 24);
linearLayoutRoamIOLatLong.setVisibility(View.VISIBLE);
leftFragHolder.setVisibility(View.VISIBLE);
storageAccess.logMessage("Map Layout Collapse");
setMapExpanded(false);
System.out.println("Map Fragment Collapse");
}
constraintMap.applyTo(constraintLayout);
break;
我有一个具有展开和折叠功能的地图片段。因此,当我展开地图时,我想隐藏 LinearLayout,当我折叠时,我想显示该布局。
但是 setVisibility(View.INVISIBLE);
不工作。当我调试应用程序时,我可以看到编译器正在读取该行,但仍然无法正常工作。
这是我的 XML 文件
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/main_fragment_constraint_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
tools:context=".MainActivity"
tools:visibility="visible">
<fragment
android:id="@+id/map"
class="com.google.android.gms.maps.MapFragment"
android:layout_width="590dp"
android:layout_height="550dp"
android:layout_marginStart="24dp"
android:layout_marginTop="110dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:context="com.korechi.roamioapp.MainActivity"
tools:layout="@layout/activity_main_left_hand" />
<org.ros.android.view.RosImageView
android:id="@+id/cameraView"
android:layout_width="590dp"
android:layout_height="550dp"
android:layout_marginStart="24dp"
android:layout_marginTop="100dp"
android:background="@color/black"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:context="com.korechi.seekerapp.MainActivity"
tools:layout="@layout/activity_main_left_hand" />
<Button
android:id="@+id/viewToggleBtn"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:alpha="0.8"
android:background="@drawable/ic_sharp_arrow"
app:layout_constraintStart_toEndOf="@id/mapSnapBtn"
app:layout_constraintTop_toTopOf="@id/mapSnapBtn" />
<ImageView
android:id="@+id/imageView"
android:layout_width="590dp"
android:layout_height="520dp"
android:layout_marginStart="24dp"
android:layout_marginTop="100dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:context="com.korechi.roamioapp.MainActivity"
tools:layout="@layout/activity_main_left_hand" />
<org.ros.android.view.RosTextView
android:id="@+id/speedROS"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="@+id/totalAreaRos"
app:layout_constraintTop_toTopOf="@+id/totalAreaRos" />
<org.ros.android.view.RosTextView
android:id="@+id/rtkStat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="@color/black"
app:layout_constraintStart_toStartOf="@+id/rtkLED"
app:layout_constraintTop_toBottomOf="@+id/rtkLED" />
<org.ros.android.view.RosTextView
android:id="@+id/lidarStat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="@color/black"
app:layout_constraintStart_toStartOf="@+id/lidarLED"
app:layout_constraintTop_toBottomOf="@+id/lidarLED" />
<org.ros.android.view.RosTextView
android:id="@+id/spreaderStat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="@color/black"
app:layout_constraintStart_toStartOf="@+id/spreaderLED"
app:layout_constraintTop_toBottomOf="@+id/spreaderLED" />
<Button
android:id="@+id/rtkLED"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:background="@drawable/grey_rounded_button"
android:text="RTK"
app:layout_constraintEnd_toStartOf="@+id/lidarLED"
app:layout_constraintTop_toTopOf="@+id/lidarLED" />
<Button
android:id="@+id/lidarLED"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="50dp"
android:background="@drawable/grey_rounded_button"
android:text="LiDAR"
app:layout_constraintEnd_toStartOf="@+id/roamIOLogo"
app:layout_constraintTop_toTopOf="@+id/roamIOLogo" />
<LinearLayout
android:id="@+id/linearLayoutRoamIOLatLong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="@id/cameraView"
app:layout_constraintTop_toBottomOf="@+id/cameraView">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textLatitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="22dp"
android:layout_marginBottom="15dp"
android:text="Latitude"
android:textColor="@android:color/black"
android:textSize="18sp" />
<org.ros.android.view.RosTextView
android:id="@+id/latitudeTextView"
android:layout_width="150dp"
android:layout_height="25dp"
android:layout_marginStart="16dp"
android:background="@drawable/textviewshape"
android:textAlignment="center"
android:textColor="@android:color/black"
android:textSize="18sp"
app:layout_constraintStart_toEndOf="@+id/textLatitude"
app:layout_constraintTop_toTopOf="@+id/textLatitude" />
<TextView
android:id="@+id/textLongitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:text="Longitude"
android:textColor="@android:color/black"
android:textSize="18sp"
app:layout_constraintStart_toEndOf="@+id/latitudeTextView"
app:layout_constraintTop_toTopOf="@+id/latitudeTextView" />
<org.ros.android.view.RosTextView
android:id="@+id/longitudeTextView"
android:layout_width="150dp"
android:layout_height="25dp"
android:layout_marginStart="16dp"
android:background="@drawable/textviewshape"
android:textAlignment="center"
android:textColor="@android:color/black"
android:textSize="18sp"
app:layout_constraintStart_toEndOf="@+id/textLongitude"
app:layout_constraintTop_toTopOf="@+id/textLongitude" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textHeading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="22dp"
android:text="Heading"
android:textColor="@android:color/black"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="@+id/textLongitude"
app:layout_constraintTop_toBottomOf="@+id/textLongitude" />
<org.ros.android.view.RosTextView
android:id="@+id/headingTextView"
android:layout_width="150dp"
android:layout_height="25dp"
android:layout_marginStart="16dp"
android:background="@drawable/textviewshape"
android:textAlignment="center"
android:textColor="@android:color/black"
android:textSize="18sp"
app:layout_constraintStart_toEndOf="@+id/textHeading"
app:layout_constraintTop_toTopOf="@+id/textHeading" />
<TextView
android:id="@+id/textAltitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="26dp"
android:text="Altitude"
android:textColor="@android:color/black"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="@+id/textLatitude"
app:layout_constraintTop_toBottomOf="@+id/textLatitude" />
<org.ros.android.view.RosTextView
android:id="@+id/altitudeTextView"
android:layout_width="150dp"
android:layout_height="25dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="17dp"
android:background="@drawable/textviewshape"
android:textAlignment="center"
android:textColor="@android:color/black"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/timeTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="480dp"
android:text="Time"
android:textColor="@android:color/black"
android:textSize="30sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/roamIOLogo" />
<org.ros.android.view.RosTextView
android:id="@+id/pointsHelperTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="@+id/linearLayout"
app:layout_constraintTop_toTopOf="@+id/linearLayout" />
<org.ros.android.view.RosTextView
android:id="@+id/rapgPointsTextView"
android:layout_width="wrap_content"
android:layout_height="13dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toStartOf="@+id/pointsHelperTextView"
app:layout_constraintTop_toTopOf="@+id/pointsHelperTextView" />
<org.ros.android.view.RosTextView
android:id="@+id/waypointsCoveredTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toStartOf="@+id/rapgPointsTextView"
app:layout_constraintTop_toTopOf="@id/linearLayout" />
<org.ros.android.view.RosTextView
android:id="@+id/totalDistanceRos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toStartOf="@id/rapgPointsTextView"
app:layout_constraintTop_toTopOf="@id/linearLayout" />
<org.ros.android.view.RosTextView
android:id="@+id/totalAreaRos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toStartOf="@id/totalDistanceRos"
app:layout_constraintTop_toTopOf="@id/linearLayout" />
<Button
android:id="@+id/batteryInfoBtn"
android:layout_width="130dp"
android:layout_height="40dp"
android:layout_marginStart="20dp"
android:layout_marginTop="4dp"
android:background="@drawable/battery"
android:text="Battery %"
android:textAlignment="center"
android:textSize="18sp"
app:layout_constraintStart_toEndOf="@id/settingsBtn"
app:layout_constraintTop_toTopOf="@id/settingsBtn" />
<org.ros.android.view.RosTextView
android:id="@+id/programStatusTextView"
android:layout_width="590dp"
android:layout_height="28dp"
android:layout_marginBottom="6dp"
android:background="@drawable/textviewshape"
android:textAlignment="center"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/map"
app:layout_constraintStart_toStartOf="@+id/map" />
<ProgressBar
android:id="@+id/batteryIndicaterBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="240dp"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="1dp"
android:visibility="visible"
app:layout_constraintStart_toEndOf="@+id/batteryInfoBtn"
app:layout_constraintTop_toTopOf="@+id/batteryInfoBtn" />
<org.ros.android.view.RosTextView
android:id="@+id/batteryPercentageTxtView"
android:layout_width="240dp"
android:layout_height="40dp"
android:layout_marginTop="6dp"
android:textAlignment="center"
android:textColor="@android:color/black"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="@+id/batteryIndicaterBar"
app:layout_constraintTop_toTopOf="@+id/batteryIndicaterBar" />
<ImageView
android:id="@+id/roamIOLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:src="@drawable/romaio_logo"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/EStopBtn"
android:layout_width="140dp"
android:layout_height="140dp"
android:layout_marginEnd="50dp"
android:layout_marginBottom="50dp"
android:background="@drawable/e_stop"
android:text="@string/estop"
android:textColor="@android:color/white"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@id/left_main_layout"
app:layout_constraintEnd_toStartOf="@id/left_main_layout" />
<Button
android:id="@+id/settingsBtn"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_marginStart="20dp"
android:layout_marginTop="16dp"
android:background="@drawable/gear"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/expandBtn"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/expand"
android:textAlignment="textStart"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="@id/left_main_layout"
app:layout_constraintTop_toTopOf="@id/left_main_layout" />
<Button
android:id="@+id/magnetBtn"
android:layout_width="60dp"
android:layout_height="60dp"
android:background="@drawable/ic_magnet_01"
android:textAlignment="textStart"
app:layout_constraintStart_toStartOf="@id/left_main_layout"
app:layout_constraintTop_toTopOf="@id/left_main_layout" />
<Button
android:id="@+id/clearMapBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginEnd="56dp"
android:alpha="0.80"
android:text="Clear"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="@id/map"
app:layout_constraintTop_toTopOf="@id/map" />
<Button
android:id="@+id/expandMapBtn"
android:layout_width="55dp"
android:layout_height="50dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="8dp"
android:background="@drawable/expand_map"
android:visibility="visible"
app:layout_constraintEnd_toStartOf="@id/clearMapBtn"
app:layout_constraintRight_toLeftOf="@+id/clearMapBtn"
app:layout_constraintTop_toTopOf="@id/map" />
<Button
android:id="@+id/mapSnapBtn"
android:layout_width="55dp"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp"
android:alpha="0.80"
android:background="@drawable/camera_icon"
app:layout_constraintStart_toStartOf="@id/map"
app:layout_constraintTop_toTopOf="@id/map" />
<Button
android:id="@+id/saveMapBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginTop="0dp"
android:alpha="0.80"
android:text="Save Heat Map"
app:layout_constraintStart_toEndOf="@+id/viewToggleBtn"
app:layout_constraintTop_toTopOf="@+id/viewToggleBtn" />
<Button
android:id="@+id/spreaderLED"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:background="@drawable/grey_rounded_button"
android:text="Spreader"
app:layout_constraintEnd_toStartOf="@id/rtkLED"
app:layout_constraintTop_toTopOf="@id/rtkLED" />
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:layout_editor_absoluteX="640dp"
tools:layout_editor_absoluteY="1dp">
<FrameLayout
android:id="@+id/left_frag_holder"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:id="@+id/left_main_layout"
android:layout_width="399dp"
android:layout_height="396dp"
android:baselineAligned="false"
android:orientation="horizontal"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="@+id/linearLayout"
app:layout_constraintEnd_toEndOf="@+id/linearLayout">
<LinearLayout
android:id="@+id/left_side_layout"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="vertical">
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
<com.korechi.roamioapp.Views.VirtualJoystickView
android:id="@+id/left_virtual_joystick"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_gravity="center"
android:layout_weight="4"
android:adjustViewBounds="true" />
<View
android:layout_width="0dip"
android:layout_height="0dip"
android:layout_weight="0" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
这是我调用 setVisibility()
函数的代码
case R.id.expandMapBtn:
mVib.vibrate(50);
storageAccess.logMessage("Expand button click");
expandMapBtn.startAnimation(myAnim);
constraintMap.clone(constraintLayout);
constraintMap.clear(R.id.map, ConstraintSet.START);
constraintMap.clear(R.id.map, ConstraintSet.TOP);
constraintMap.applyTo(constraintLayout);
constraintMap.connect(R.id.map, ConstraintSet.START, R.id.main_fragment_constraint_layout, ConstraintSet.START);
constraintMap.connect(R.id.map, ConstraintSet.TOP, R.id.main_fragment_constraint_layout, ConstraintSet.TOP);
System.out.println(isViewExpanded());
linearLayoutRoamIOLatLong = findViewById(R.id.linearLayoutRoamIOLatLong);
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int height = displayMetrics.heightPixels;
int width = displayMetrics.widthPixels;
if (!isMapExpanded()) {
constraintMap.constrainHeight(R.id.map, height);
constraintMap.constrainWidth(R.id.map, width);
constraintMap.connect(R.id.map, ConstraintSet.START, R.id.main_fragment_constraint_layout, ConstraintSet.START);
constraintMap.connect(R.id.map, ConstraintSet.TOP, R.id.main_fragment_constraint_layout, ConstraintSet.TOP);
constraintMap.setMargin(R.id.map, ConstraintSet.START, 0);
constraintMap.setMargin(R.id.map, ConstraintSet.TOP, 150);
constraintMap.connect(R.id.longitudeTextView, ConstraintSet.INVISIBLE, R.id.main_fragment_constraint_layout, ConstraintSet.TOP);
linearLayoutRoamIOLatLong.setVisibility(View.INVISIBLE);
leftFragHolder.setVisibility(View.INVISIBLE);
storageAccess.logMessage("Map Layout Expanded");
setMapExpanded(true);
System.out.println("Map Fragment Expanded");
} else {
constraintMap.constrainHeight(R.id.map, 850);
constraintMap.constrainWidth(R.id.map, 890);
constraintMap.connect(R.id.map, ConstraintSet.START, R.id.main_fragment_constraint_layout, ConstraintSet.START);
constraintMap.connect(R.id.map, ConstraintSet.TOP, R.id.main_fragment_constraint_layout, ConstraintSet.TOP);
constraintMap.setMargin(R.id.map, ConstraintSet.START, 24);
constraintMap.setMargin(R.id.map, ConstraintSet.TOP, 150);
linearLayoutRoamIOLatLong.setVisibility(View.VISIBLE);
leftFragHolder.setVisibility(View.VISIBLE);
storageAccess.logMessage("Map Layout Collapse");
setMapExpanded(false);
System.out.println("Map Fragment Collapse");
}
constraintMap.applyTo(constraintLayout);
break;
我像这样使用 LayoutParams 来水平隐藏一个接一个的元素:
LinearLayout.LayoutParams params_visible = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layoutToBeVisible.setLayoutParams(params_visible);
LinearLayout.LayoutParams params_invisible = new LinearLayout.LayoutParams(
0, LinearLayout.LayoutParams.WRAP_CONTENT);
layoutToBeInvisible.setLayoutParams(params_invisible);
LayoutParams第一个参数是宽度,第二个参数是高度。
在 FrameLayout
中覆盖您的片段 xml 部分,然后在 Java 代码中对该 FrameLayout 对象调用 setVisibility()。
更新:
为了隐藏存储在您的视图组下的视图,即线性布局,将您的线性布局与 Framelayout 作为父级包围起来。
我找到了解决方法。我正在将 Linearlayout 约束设置到屏幕外,因此它不再可见,并以编程方式返回设置默认约束。
我所做的是在单击展开按钮时以编程方式将设置约束添加到 app:layout_constraintBottom_toTopOf="parent"
。(展开时)
然后在折叠时以编程方式设置默认约束和边距。
app:layout_constraintBottom_toBottomOf="@+id/linearLayout"
app:layout_constraintEnd_toEndOf="@+id/linearLayout"
这是解决方案的代码
case R.id.expandMapBtn:
mVib.vibrate(50);
storageAccess.logMessage("Expand button click");
expandMapBtn.startAnimation(myAnim);
constraintMap.clone(constraintLayout);
constraintMap.clear(R.id.map, ConstraintSet.START);
constraintMap.clear(R.id.map, ConstraintSet.TOP);
constraintMap.applyTo(constraintLayout);
constraintMap.connect(R.id.map, ConstraintSet.START, R.id.main_fragment_constraint_layout, ConstraintSet.START);
constraintMap.connect(R.id.map, ConstraintSet.TOP, R.id.main_fragment_constraint_layout, ConstraintSet.TOP);
constraintMap.setAlpha(R.id.linearLayoutRoamIOLatLong,100);
System.out.println(isViewExpanded());
linearLayoutRoamIOLatLong = findViewById(R.id.linearLayoutRoamIOLatLong);
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int height = displayMetrics.heightPixels;
int width = displayMetrics.widthPixels;
if (!isMapExpanded()) {
constraintMap.constrainHeight(R.id.map, height);
constraintMap.constrainWidth(R.id.map, width);
constraintMap.connect(R.id.map, ConstraintSet.START, R.id.main_fragment_constraint_layout, ConstraintSet.START);
constraintMap.connect(R.id.map, ConstraintSet.TOP, R.id.main_fragment_constraint_layout, ConstraintSet.TOP);
constraintMap.setMargin(R.id.map, ConstraintSet.START, 0);
constraintMap.setMargin(R.id.map, ConstraintSet.TOP, 150);
constraintMap.connect(R.id.linearLayoutRoamIOLatLong, ConstraintSet.BOTTOM, R.id.main_fragment_constraint_layout, ConstraintSet.TOP);
linearLayoutRoamIOLatLong.setVisibility(View.INVISIBLE);
leftFragHolder.setVisibility(View.INVISIBLE);
storageAccess.logMessage("Map Layout Expanded");
setMapExpanded(true);
System.out.println("Map Fragment Expanded");
} else {
constraintMap.constrainHeight(R.id.map, 850);
constraintMap.constrainWidth(R.id.map, 890);
constraintMap.connect(R.id.map, ConstraintSet.START, R.id.main_fragment_constraint_layout, ConstraintSet.START);
constraintMap.connect(R.id.map, ConstraintSet.TOP, R.id.main_fragment_constraint_layout, ConstraintSet.TOP);
constraintMap.connect(R.id.linearLayoutRoamIOLatLong, ConstraintSet.LEFT, R.id.main_fragment_constraint_layout, ConstraintSet.LEFT);
constraintMap.connect(R.id.linearLayoutRoamIOLatLong, ConstraintSet.BOTTOM, R.id.main_fragment_constraint_layout, ConstraintSet.BOTTOM);
constraintMap.setMargin(R.id.map, ConstraintSet.START, 24);
constraintMap.setMargin(R.id.map, ConstraintSet.TOP, 150);
// constraintMap.setMargin(R.id.linearLayoutRoamIOLatLong, ConstraintSet.TOP, 75);
constraintMap.setMargin(R.id.linearLayoutRoamIOLatLong, ConstraintSet.BOTTOM, 25);
constraintMap.setMargin(R.id.linearLayoutRoamIOLatLong, ConstraintSet.START, 24);
linearLayoutRoamIOLatLong.setVisibility(View.VISIBLE);
leftFragHolder.setVisibility(View.VISIBLE);
storageAccess.logMessage("Map Layout Collapse");
setMapExpanded(false);
System.out.println("Map Fragment Collapse");
}
constraintMap.applyTo(constraintLayout);
break;