【问题标题】:XML Absolute Layout put image in Bottom Left and Bottom RightXML 绝对布局将图像放在左下角和右下角
【发布时间】:2012-08-30 13:19:46
【问题描述】:

您好,我想制作一个应用程序,其中我正在使用绝对布局,并且在该布局中我正在使用两个图像我想将一个图像放在左下角,另一个放在右下角你能帮我吗? xml 或 java

我的代码是

  <AbsoluteLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" android:layout_marginLeft="60dp"
android:layout_marginBottom="60dp"
android:id="@+id/mainLayout">
 <ImageView android:id="@+id/img1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:src="@drawable/hk1" />
  <ImageView android:id="@+id/imgDel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/kitty"
         android:layout_gravity="left"
         />
 <ImageView android:id="@+id/imgIcon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/delete"
        android:layout_gravity="right"
         />

 </AbsoluteLayout>

【问题讨论】:

  • 但是我已经创建了很多基于绝对布局的东西,如果我改变布局我也必须在 java 中改变很多东西
  • No user370305 如果我手动输入 x,y 值,它会显示

标签: android xml android-layout view


【解决方案1】:

使用类似的东西

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ImageView
        android:id="@+id/big_image"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:src="@drawable/bigimage"/>
    <ImageView
        android:id="@+id/little_image"
        android:layout_width="50dip"
        android:layout_height="50dip"
        android:layout_alignRight="@id/big_image"
        android:layout_alignBottom="@id/big_image"
        android:src="@drawable/littleimage"/>
</RelativeLayout>

引用自relative layout aligning images about right bottom corner

【讨论】:

    猜你喜欢
    • 2016-06-08
    • 2013-12-22
    • 2017-05-19
    • 2017-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-13
    • 2021-08-21
    相关资源
    最近更新 更多