簡體   English   中英

在約束布局 Android 中創建自定義布局

[英]Create Custom Layout in Constraint Layout Android

如何根據圖中所示的布局在約束布局中進行自定義布局在此處輸入圖片說明

左父母 + 右父母的圖標

從左到右圖標 + 右父級的 EditText

帶有右重力的按鈕 INSIDE EditText

EditText 中的自定義背景

嘗試這樣的事情

<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