buttons becomming small when in run the app the buttons are becoming small.... please help me with the solution.. I have attached the image.
<Button
android:id="@ id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/roundtext"
android:text="Login"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.185"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.584" />
CodePudding user response:
The size of the buttons is as expected - their width and height wrap the button's text completely.
The problem is probably with your custom background @drawable/roundtext
which makes the buttons look a little weird.
CodePudding user response:
Try giving some padding
to the button.
The padding is expressed in pixels for the left, top, right and bottom parts of the view. Padding can be used to offset the content of the view by a specific number of pixels. For instance, a left padding of 2 will push the view’s content by 2 pixels to the right of the left edge. The inner space of an element i.e.padding is space inside the element’s border
.
So, either you can try adding
android:padding="5dp"
where padding is added for all four sides ,or you can try adding padding
specific to your required sides like below.
android:paddingStart="5dp"
android:paddingEnd="5dp"
So, your code may look like something as given below.
<Button
android:id="@ id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/roundtext"
android:text="Login"
android:paddingStart="5dp"
android:paddingEnd="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.185"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.584" />