靠右显示:用 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>
本文详细介绍了在Android开发中如何使用layout_margin属性来调整视图组件与屏幕边界之间的距离。包括了左右上下四个方向的间距设置方法,并通过一个具体的例子展示了如何实现元素靠右对齐的效果。
3688

被折叠的 条评论
为什么被折叠?



