Android 我想有一个可拉拔按钮与顶部位置提示水平

Android 我想有一个可拉拔按钮与顶部位置提示水平,android,android-layout,android-button,Android,Android Layout,Android Button,我想有一个可拉拔按钮与顶部位置提示水平 ] 我试图这样做,但我不知道如何显示提示文本或上面的文本 <Button android:id="@+id/test" style="@style/Widget.MaterialComponents.Chip.Filter" android:layout_width="match_parent" android:layout_height="79dp" android:background="@colo

我想有一个可拉拔按钮与顶部位置提示水平

]

我试图这样做,但我不知道如何显示提示文本或上面的文本

    <Button
    android:id="@+id/test"
    style="@style/Widget.MaterialComponents.Chip.Filter"
    android:layout_width="match_parent"
    android:layout_height="79dp"
    android:background="@color/float_transparent"
    android:drawableRight="@drawable/ic_clear"
    android:textAppearance="@style/Widget.MaterialComponents.Chip.Filter"
    android:hint="@string/title_About"
    android:text="@string/title_About"
    android:textAlignment="textStart"
    android:textColor="@color/links"
    android:textColorHint="@color/gray_btn_bg_color"
    android:textSize="20dp"/>


首先-不要在视图上使用固定大小-这会使您的屏幕不响应

第二,您可以使用以下方法快速实现此目标:

<Button
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="8dp"
    android:text="Jun 10 ,2018"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<Button
    android:id="@+id/textView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:text="TextView"
    app:layout_constraintBottom_toTopOf="@+id/textView4"
    app:layout_constraintStart_toStartOf="@+id/textView4" />

试试这个

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


<Button
    android:id="@+id/text1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginStart="8dp"
    android:hint="DUE DATE"
    android:background="@android:color/white"
    android:textAlignment="viewStart"
    android:gravity="center"
    android:textSize="18sp"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<Button
    android:id="@+id/text2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:text="Jun 10 ,2018"
    android:textAlignment="viewStart"
    android:gravity="center"
    android:textSize="25sp"
    android:background="@android:color/white"
    android:textColor="@android:color/holo_blue_dark"
    app:layout_constraintTop_toBottomOf="@+id/text1"
    app:layout_constraintStart_toStartOf="parent" />
</android.support.constraint.ConstraintLayout>