Как вложить макет ограничения в макет кадра в XML? - PullRequest
0 голосов
/ 23 мая 2018

Привет, я новичок в Android Studio и в настоящее время в xml Activity_main у меня есть этот макет ограничения с несколькими текстовыми представлениями.

<android.support.constraint.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/country_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="edu.monash.fit2081.countryinfo.CountryDetails">

<TextView
    android:id="@+id/textView"
    android:layout_width="150dp"
    android:layout_height="25dp"
    //some code here

Теперь я хочу изменить его на фрагмент и выполнить это действие.в качестве нижнего фрагмента. Я сделал свой фрагмент следующим образом, но как вставить макет выше в макет моего фрейма?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:id="@+id/content_main"
                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="edu.monash.fit2081.database_4.MainActivity">

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 android:id="@+id/fragment_top"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:background="@drawable/fragment_border"
        />

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 android:id="@+id/country_detail"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:layout_below="@id/fragment_top"
                 android:background="@drawable/fragment_border"
        />

    </RelativeLayout>

Любая помощь будет оценена!

1 Ответ

0 голосов
/ 23 мая 2018

FrameLayout - это ViewGroup, также как и RelativeLayout:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 android:id="@+id/country_detail"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:layout_below="@id/fragment_top"
                 android:background="@drawable/fragment_border"
        >
    <android.support.constraint.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/country_detail"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="edu.monash.fit2081.countryinfo.CountryDetails">

    <TextView
        android:id="@+id/textView"
        android:layout_width="150dp"
        android:layout_height="25dp"
        />

</FrameLayout>
...