如何在片段顶部启用此textView。即使片段彼此改变,我也希望它保持静止。我没有运气使它在顶部。这是我的布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.skwebviewapp.MainActivity">
<fragment
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/mainFragment"
tools:layout="@layout/fragment_main" />
<TextView
android:layout_width="wrap_content"
android:layout_height="16dp"
android:id="@+id/textView"
android:text="@string/app_name"/>
</LinearLayout>
答案 0 :(得分:0)
You can try this with RelativeLayout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="16dp"
android:text="@string/app_name" />
<fragment xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map_view_fargment"
android:name="com.google.android.gms.maps.MapFragment"
class="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="40dp"
/>
</LinearLayout>
答案 1 :(得分:0)
尝试以下代码,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.skwebviewapp.MainActivity”
android:orientation=“vertical"
android:weightSum=“1.0">
<TextView
android:layout_width="wrap_content"
android:layout_height=“0dp”
android:layout_weight=“0.10"
android:id="@+id/textView"
android:text="@string/app_name”/>
<fragment
android:layout_width="match_parent"
android:layout_height=“0dp"
android:layout_weight=“0.90"
android:id="@+id/mainFragment"
tools:layout="@layout/fragment_main" />
</LinearLayout>