我的布局有问题,包含2个片段:" map" -top fragment和" fragmentLayout with details" - 底部一个。 我希望我的地图片段在底部从顶部到第二个布局边缘,但我找不到合适的解决方案。我的底部布局覆盖了所有的屏幕空间,我根本看不到地图。
这是我的布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="1"
android:name="com.google.android.gms.maps.MapFragment"/>
<fragment class="com.softserve.youRun.Fragment.WorkoutDetailsFragment"
android:id="@+id/workout_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
锻炼细节片段布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/row_gradient">
<TextView
android:id="@+id/textView0"
android:textColor="#002F2F"
android:layout_margin="5dp"
android:text="Date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TextView
android:id="@+id/textDateDetails"
android:textColor="#002F2F"
android:text="00.00.00"
android:layout_margin="5dp"
android:layout_alignParentEnd="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TextView
android:id="@+id/textView1"
android:textColor="#002F2F"
android:layout_margin="5dp"
android:text="Distance(m)"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/textView0"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TextView
android:id="@+id/textDistanceDetails"
android:textColor="#002F2F"
android:text="00.00"
android:layout_margin="5dp"
android:layout_alignParentEnd="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textDateDetails"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TextView
android:id="@+id/textView2"
android:textColor="#002F2F"
android:text="Duration"
android:layout_margin="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textView1"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TextView
android:id="@+id/textDurationDetails"
android:textColor="#002F2F"
android:text="00:00:00"
android:layout_margin="5dp"
android:layout_alignParentEnd="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textDistanceDetails"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TextView
android:id="@+id/textView3"
android:textColor="#002F2F"
android:text="Calories"
android:layout_margin="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textView2"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TextView
android:id="@+id/textCaloriesDetails"
android:textColor="#002F2F"
android:text="000"
android:layout_margin="5dp"
android:layout_alignParentEnd="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textDurationDetails"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
<TextView
android:id="@+id/textView4"
android:textColor="#002F2F"
android:text="Coordinates"
android:layout_margin="5dp"
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textView3"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TextView
android:id="@+id/textCoordinatesDetails"
android:textColor="#002F2F"
android:text="0"
android:layout_margin="5dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textCaloriesDetails"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
</RelativeLayout>
答案 0 :(得分:0)
您的布局文件应如下所示。屏幕在两个片段中平分:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="1"
android:name="com.google.android.gms.maps.MapFragment"/>
<fragment class="com.softserve.youRun.Fragment.WorkoutDetailsFragment"
android:id="@+id/workout_details"
android:layout_width="match_parent"
android:layout_height="0dp"//added this line
android:layout_weight="1"/> // and this too
</LinearLayout>