Starting at API level 21, by default, a Button (which is called a raised button in Material Design) has an upward mark and a pressed height. For example, at API level 23, Values ββare 2dp and 6dp, respectively.
Your ProgressBar is in the correct position, but below the Button , because its height is 0.
So, just by adding a height of more than 6 dp to your ProgressBar , you can do it above the button.
android:elevation="7dp"
In addition, you can create a layout to simulate a button and create a button style:
<LinearLayout style="@style/Widget.AppCompat.Button" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:orientation="horizontal"> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="Button" android:textAppearance="@style/TextAppearance.AppCompat.Button"/> <ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout>
The second approach is more compatible with hyphenation, since the height may change in a future version.
For example, at API level 21, the values ββwere 1dp and 3dp
<dimen name="button_elevation_material">1dp</dimen> <dimen name="button_pressed_z_material">2dp</dimen>
This is API Level 23
<dimen name="button_elevation_material">2dp</dimen> <dimen name="button_pressed_z_material">4dp</dimen>
source share