现在的位置: 首页 > 综合 > 正文

android:layout_marginLeft等的简单用法

2018年05月16日 ⁄ 综合 ⁄ 共 615字 ⁄ 字号 评论关闭

靠右显示:用 android:layout_marginLeft,意思是距离左边框的距离;

靠左显示:用android:layout_marginRight,意思是距离右边框的距离。

同理,

android:layout_marginTop: 距离上边框

android:layout_marginBottom: 距离下边框

    

下面,是靠右显示的例子:

<LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="100dp"
                android:layout_alignParentRight="true"   // 这个可有可无
                android:orientation="vertical"
                 >

                <TextView
                    android:id="@+id/text_timer"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="timer" />
            </LinearLayout>

抱歉!评论已关闭.