【问题标题】:How can i create this view?我怎样才能创建这个视图?
【发布时间】:2017-07-06 22:57:37
【问题描述】:

如何绘制此视图? ......

【问题讨论】:

  • 使用相对布局
  • 使用约束布局

标签: android listview view android-custom-view


【解决方案1】:

使用相对布局进行定位

使用没有背景颜色的 (X) 图像按钮并将其放置在中心 使用

<ImageButton android:id="@+id/btnid" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:background="@drawable/(X)image">
</ImageButton>

【讨论】:

    【解决方案2】:

    您已提出 2 个问题 1)如何在android中绘制这个xml布局?

    你应该尝试一些 xml 代码并发布你卡住的地方

    2)如何将 (X) 按钮放置在布局的中心底部。

    为此,使用父布局作为“相对布局”并将您的视图(假设您有 ImageView)设置为 layout_alignParentBottom = true 和 layout_centerHorizo​​ntal = true。您也可以参考下面的代码。

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Testing"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"/>
    
    </RelativeLayout>
    

    【讨论】:

      猜你喜欢
      • 2017-08-11
      • 2011-04-27
      • 2022-10-24
      • 1970-01-01
      • 2021-07-10
      • 1970-01-01
      • 2010-11-03
      • 2021-10-30
      • 2018-01-14
      相关资源
      最近更新 更多