简体   繁体   English

在约束布局 Android 中创建自定义布局

[英]Create Custom Layout in Constraint Layout Android

How to make custom layout in constraint layout according to the layout shown in image如何根据图中所示的布局在约束布局中进行自定义布局在此处输入图片说明

Icon at left-parent + right-parent左父母 + 右父母的图标

EditText at left-toRight-icon + right-parent从左到右图标 + 右父级的 EditText

Button INSIDE EditText with right-gravity带有右重力的按钮 INSIDE EditText

Custom background in EditText EditText 中的自定义背景

Try something like this尝试这样的事情

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <ImageView
        android:id="@+id/iconImage"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:layout_marginTop="8dp"
        android:layout_marginLeft="8dp"
        android:src="@mipmap/ic_launcher_round"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

    <EditText
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        app:layout_constraintLeft_toRightOf="@id/iconImage"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintRight_toLeftOf="@id/imageBtn"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:hint="I want to..." />

    <ImageButton
        android:id="@+id/imageBtn"
        android:layout_width="48dp"
        android:layout_height="48dp"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintRight_toRightOf="parent"/>

</android.support.constraint.ConstraintLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM