android - 底部边距或填充在 android 上的 xml 中的相对布局中不起作用

标签 android imageview padding margin

我有一个 RelativeLayout 用于 ListView 中的一行。该行看起来像,

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayout1" 
    android:layout_width="wrap_content"
    android:layout_height="fill_parent">

    <ImageView
        android:id="@+id/placeDetailIcon_Img"
        android:layout_height="50dp"
        android:layout_width="50dp"
        android:layout_alignParentLeft="true" 
        android:paddingBottom="20dp"
        android:paddingTop="20dp" 
        android:paddingLeft="20dp"
        android:paddingRight="20dp"/>
</RelativeLayout>

我也用margin试了一下:

 <ImageView
    android:layout_height="50dp"
    android:layout_width="50dp"
    android:id="@+id/placeDetailIcon_Img" 
    android:layout_alignParentLeft="true" 
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp"
    android:layout_marginLeft="10dp"
    android:layout_marginBottom="10dp">

既不在 ImageView 周围应用边距或填充。如何创建这种类型的间距?

最佳答案

你可以在我的工作中使用它:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">  

     <ImageView
         android:id="@+id/imageView1"
         android:layout_width="50dp"
         android:layout_height="50dp"
         android:layout_alignParentLeft="true"
         android:layout_alignParentTop="true"
         android:layout_marginLeft="15dp"
         android:layout_marginTop="15dp" />

</RelativeLayout>

希望这对您有所帮助。

关于android - 底部边距或填充在 android 上的 xml 中的相对布局中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10237210/

相关文章:

android - 更改 ListView 或回收 View 的单个项目的布局

android - 向鳍状肢添加多个 ImageView 并将图像从 url 加载到这些 ImageView

SwiftUI:NavigationLink 在最小的 10 行示例中导致不需要的填充

opencv - OpenCV-反卷积中的边界伪像

java - 每次应用程序从后台返回时如何刷新 Webview?

android - Facebook App Key Hash 的使用

android - 进度条 : set location/position in Canvas

方向更改后Android DialogFragment消失

html - margin 底部不起作用?

android - 如何在android中显示外部图像?