问题描述
在以下代码中:
<LinearLayout
android:id="@+id/activity_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"
android:orientation="vertical"
tools:context="com.example.android.ashokaquiz.MainActivity">
@dimen/activity_vertical_margin
的作用是什么?我找不到任何文档.我知道什么是填充.我只想知道@dimen/activity_vertical_margin
位.
What does @dimen/activity_vertical_margin
do? I cannot find any documentation for it. I know what padding is. I just want to know about the @dimen/activity_vertical_margin
bit.
谢谢.
推荐答案
@dimen是指尺寸,它是一个文件,您可以在其中定义尺寸,以便以后在任何布局文件中使用它们.
@dimen refers to dimension and it's a file where you define dimensions to use them later from in any layout file.
它位于res/values/dimens
中.这是该文件的示例:
It's located in res/values/dimens
. Here's what a sample of the file look like:
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
这里activity_veritcal_margin = 16 dp.
Here activity_veritcal_margin = 16 dp.
并像这样使用它:
<LinearLayout
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin">
在这里,我们将此线性布局的底部填充设为16dp.
Here we give this linear layout a bottom padding with 16dp.
这篇关于@ dimen/activity_vertical_margin有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!