微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法更改 android studio 中按钮的形状

如何解决无法更改 android studio 中按钮的形状

所以我想改变android studio中按钮的形状。我已经尝试并遵循了多个指南,但似乎没有任何效果。我想我在其他一些文件中搞砸了一些东西,比如主题

我试过这个https://stackoverflow.com/a/18879660/14973568https://www.youtube.com/watch?v=plQIpqBcdQE 并且 This was the last attempt at resolving the problem

图中代码

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#F4CD47"/>
    <corners android:topRighTradius="120dp"
        android:topLefTradius="120dp"
        android:bottomLefTradius="120dp"
        android:bottomrighTradius="120dp" />
</shape>    

但我只能用 backgroundTint 更改它。

rounded_button.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#fff" />
    <corners android:radius="130dp" />
</shape>

activity_game.xml:

<androidx.constraintlayout.widget.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=".game"
    android:background="#396dbf">

    <TextView
        android:id="@+id/credit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="16dp"
        android:layout_marginBottom="16dp"
        android:text="@string/creditText"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent" />

    <ImageView
        android:id="@+id/backButton"
        android:layout_width="56dp"
        android:layout_height="56dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/back"
        android:contentDescription="Todo" />

    <ImageView
        android:id="@+id/logo"
        android:layout_width="100dp"
        android:layout_height="85dp"
        android:layout_marginTop="4dp"
        android:layout_marginEnd="16dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/logo" />

    <Button
        android:id="@+id/button1"
        android:layout_width="276dp"
        android:layout_height="56dp"
        android:layout_marginTop="380dp"
        android:background="@drawable/rounded_button"
        android:backgroundTint="#FFE500"
        android:fontFamily="sans-serif-black"
        android:textColor="#000000"
        android:textSize="14sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.496"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/button2"
        android:layout_width="276dp"
        android:layout_height="56dp"
        android:layout_marginTop="40dp"
        android:backgroundTint="#FFE500"
        android:fontFamily="sans-serif-black"
        android:textColor="#000000"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.496"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/button1" />

    <Button
        android:id="@+id/button3"
        android:layout_width="276dp"
        android:layout_height="56dp"
        android:layout_marginTop="40dp"
        android:backgroundTint="#FFE500"
        android:fontFamily="sans-serif-black"
        android:textColor="#000000"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.496"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/button2" />

    <TextView
        android:id="@+id/question"
        android:layout_width="245dp"
        android:layout_height="173dp"
        android:layout_marginTop="132dp"
        android:layout_marginEnd="80dp"
        android:background="@drawable/whiteback"
        android:text="TextView"
        android:textAlignment="center"
        android:textAllCaps="false"
        android:textColor="#000000"
        android:textSize="18sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。