Yon*_*Nir 5 android include android-layout
这是这个问题的后续问题:
我正在尝试为布局添加边距include
。我已将layout_width
和添加layout_height
到包含元素中,但边距仍然被忽略。此外,当我尝试自动完成布局 xml 文件中的“margin”一词时,该属性甚至无法识别。
那么如何为标签添加边距呢include
?
布局:
<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="@layout/main_status"
/>
<!--
As the main content view, the view below consumes the entire
space available using match_parent in both dimensions.
-->
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
<!--
android:layout_gravity="start" tells DrawerLayout to treat
this as a sliding drawer on the left side for left-to-right
languages and on the right side for right-to-left languages.
If you're not building against API 17 or higher, use
android:layout_gravity="left" instead.
-->
<!--
The drawer is given a fixed width in dp and extends the full height of
the container.
-->
<fragment
android:id="@+id/navigation_drawer"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="left"
tools:layout="@layout/fragment_navigation_drawer" />
Run Code Online (Sandbox Code Playgroud)
如您所见,LinearLayout 的高度设置为match_parent
。我仍然希望这样,但这就是当尝试在我想要包含的布局内添加边距时导致包含的布局和容器布局彼此重叠的原因。
所以我所做的就是设置paddingTop
线性布局容器的属性,从而达到我想要的效果。它在包含的布局和线性布局之间创建了一些空间。
归档时间: |
|
查看次数: |
4444 次 |
最近记录: |