android - How to make a view resize/shorten itself when a new view appears on screen? -
i have 2 views on screen, google map fragment , different custom fragment. before custom fragment appears on screen, google map fullscreen good. once new fragment appears @ bottom of screen, want google map resized takes available space not used new fragment.
ie. before new fragment
|----------------| | | | | | | | | | map | | | | | | | | | | | | | |----------------|
after new fragment
|----------------| | | | | | | | map | | | | | | | |----------------| <-- map ends here | | | new fragment | | | |----------------|
xml file:
<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_height="match_parent" android:layout_width="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout"> <android.support.design.widget.navigationview android:layout_width="200dp" android:layout_height="match_parent" app:menu="@menu/navigation_menu" android:id="@+id/navigation_menu" android:layout_gravity="start"> </android.support.design.widget.navigationview> <relativelayout android:layout_width="match_parent" android:layout_height="match_parent"> <fragment xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/map" android:name="com.google.android.gms.maps.supportmapfragment" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.damia.placefinder.activities.mapsactivity" /> <framelayout android:layout_width="match_parent" android:layout_height="300dp" android:id="@+id/container_locations" android:layout_alignparentbottom="true" android:background="@color/cardview_light_background" android:visibility="gone"> </framelayout> </relativelayout> </android.support.v4.widget.drawerlayout>
thanks
sounds time use linearlayout
, layout_weight
attribute.
<linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <fragment android:id="@+id/map" android:name="com.google.android.gms.maps.supportmapfragment" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" tools:context="com.example.damia.placefinder.activities.mapsactivity"/> <framelayout android:id="@+id/container_locations" android:layout_width="match_parent" android:layout_height="300dp" android:background="@color/cardview_light_background" android:visibility="gone"> </framelayout> </linearlayout>
if, reason, linearlayout
offends sensibilities, can constraintlayout
.
<android.support.constraint.constraintlayout android:layout_width="match_parent" android:layout_height="match_parent"> <fragment android:id="@+id/map" android:name="com.google.android.gms.maps.supportmapfragment" android:layout_width="0dp" android:layout_height="0dp" app:layout_constrainttop_totopof="parent" app:layout_constraintleft_toleftof="parent" app:layout_constraintright_torightof="parent" app:layout_constraintbottom_totopof="@+id/container_locations" tools:context="com.example.damia.placefinder.activities.mapsactivity"/> <framelayout android:id="@+id/container_locations" android:layout_width="0dp" android:layout_height="300dp" android:background="@color/cardview_light_background" android:visibility="gone" app:layout_constraintleft_toleftof="parent" app:layout_constraintright_torightof="parent" app:layout_constraintbottom_tobottomof="parent"> </framelayout> </android.support.constraint.constraintlayout>
Comments
Post a Comment