foo*_*512 2 android margin padding relativelayout android-layout
我最近试图在没有运气的情况下定位imageview的x和y坐标,似乎没有办法在Gingerbread中做到这一点.然后我决定尝试填充和边距,但是当我设置它们时,它缩小了我的imageview.我设置了250dp的左边填充,图像视图变得很小.layout_height和width设置为wrap_content.我不确定发生了什么.有谁知道为什么设置填充/边距会缩小imageview?
kco*_*ock 11
你会混淆边距和填充.边距是视图之外的区域,而填充会影响边距内的内容.

如果设置填充,那么它将影响您的可用内容区域,并假设您设置了ScaleType,它将缩小您的图像以适应可用空间.
现在,你说你已经尝试过利润,但利润率将完全符合你的要求.
例如,如果您想要从左上角ImageView放置10dp,您可以执行以下操作:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="@+id/my_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:src="@drawable/my_image_id"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
请记住,这会将其10dp置于parent边界之上.如果您的父布局也有填充,那么这将影响您的内容展示位置.
| 归档时间: |
|
| 查看次数: |
6759 次 |
| 最近记录: |