-1

I want create a button which would containe a simple hint in top and username which user input. So, now i have something like that:

 <Button
    android:id="@+id/settings_change_name"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginStart="32dp"
    android:layout_marginTop="32dp"
    android:layout_marginEnd="32dp"
    android:backgroundTint="#FFFFFF"
    android:hint="How we can call you?"
    android:minHeight="55dp"
    android:textAlignment="viewStart"
    android:textColor="@color/text_main_color"
    android:textSize="14sp"
    app:cornerRadius="10dp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

and here it is: button

But how can I separate hint from username? I tried using just text as a hint, but it still not what i'm looking for.

  • 1
    Does this answer your question? https://stackoverflow.com/a/65698528/11034109 – Sekiro Jan 14 '21 at 14:29
  • I dont think so, i want exactly button with a hint on top, not TextInput, this button will send user to another activity and there will always be a hint just like there https://imgur.com/7G6z3nC (it's russian app) – samartinell Jan 14 '21 at 14:48

1 Answers1

1

I am not sure if there's a default view to support your requirements. As a last resort, you can try the following

//use this layout as a button
    <LinearLayout
        android:id="@+id/root"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/round_btn"
        android:orientation="vertical"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <TextView
            android:id="@+id/hint_holder"
            android:padding="4dp"
            android:textSize="14sp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="How do we want to call you?" />

        <TextView
            android:id="@+id/value_holder"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="4dp"
            android:text="UserName"
            android:textSize="14sp" 
            android:textColor="#EF492D"/>
    </LinearLayout>
//round_btn drawable
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#ffffff"></solid>
    <corners android:radius="10dp"/>
</shape>

To respond to clicks, set an onClickListener to the root layout.

Sekiro
  • 1,537
  • 1
  • 7
  • 21