如何在 xml 的框架布局中嵌套约束布局?
How to nest a constraint layout in a frame layout in xml?
嗨,我是 Android Studio 的新手,目前在我的 activity_main xml 我有这个约束布局和一些文本视图。
<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
现在我想将其更改为一个片段并使 activity 作为底部 fragment.I 使我的片段像这样但是如何将上面的布局嵌套到我的框架布局中?
<?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>
任何帮助将不胜感激!
FrameLayout 和 RelativeLayout 一样是一个 ViewGroup:
<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>
嗨,我是 Android Studio 的新手,目前在我的 activity_main xml 我有这个约束布局和一些文本视图。
<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
现在我想将其更改为一个片段并使 activity 作为底部 fragment.I 使我的片段像这样但是如何将上面的布局嵌套到我的框架布局中?
<?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>
任何帮助将不胜感激!
FrameLayout 和 RelativeLayout 一样是一个 ViewGroup:
<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>