Java android studio中的布局问题。如何使我的相对布局覆盖整个屏幕,而不是停留在左上角?
这是一张使用拖放方法将相对布局添加到我的android studio项目的结果图片。这似乎发生在我的许多项目,然后解决,我不知道为什么。我不熟悉android开发以及java和xml,所以我有点困惑 以下是content_main.xml文件:Java android studio中的布局问题。如何使我的相对布局覆盖整个屏幕,而不是停留在左上角?,java,android,xml,android-layout,Java,Android,Xml,Android Layout,这是一张使用拖放方法将相对布局添加到我的android studio项目的结果图片。这似乎发生在我的许多项目,然后解决,我不知道为什么。我不熟悉android开发以及java和xml,所以我有点困惑 以下是content_main.xml文件: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.roger.myowncalculator.MainActivity"
tools:showIn="@layout/activity_main">
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.roger.myowncalculator.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
使用
而不是
android:layout_width="wrap_content"
android:layout_height="wrap_content"
包装内容意味着根据需要占用尽可能多的空间,并按照说明匹配父内容。使用
而不是
android:layout_width="wrap_content"
android:layout_height="wrap_content"
“包装内容”意味着根据需要占用尽可能多的空间,并与“家长”的意思一致。谢谢L.Kolar!!这很有道理,而且效果很好!谢谢你,L.科拉!!这很有道理,而且效果很好!
android:layout_width="wrap_content"
android:layout_height="wrap_content"