亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

是什么使按鈕背景變白,它不應該是透明的嗎?

是什么使按鈕背景變白,它不應該是透明的嗎?

炎炎設計 2022-05-12 16:25:03
正如您在此處看到的,按鈕的背景是透明的。我似乎無法在任一 xml 文件中找到它設置為白色的位置。該按鈕被識別為btnCapture代碼如下。activity_main.xml<RelativeLayout    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:id="@+id/container"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context=".MainActivity">    <TextureView        android:id="@+id/textureView"        android:layout_width="match_parent"        android:layout_height="match_parent"        android:layout_above="@+id/btnCapture" />    <Button        android:text="@string/capture"        android:id="@+id/btnCapture"        android:layout_width="wrap_content"        android:layout_height="92dp"        android:background="@drawable/rounded_button"        android:layout_alignParentBottom="true"        android:layout_centerInParent="true"        tools:layout_editor_absoluteX="157dp"        tools:layout_editor_absoluteY="202dp" /></RelativeLayout>rounded_button.xml<shape xmlns:android="http://schemas.android.com/apk/res/android"    android:shape="oval">    <stroke android:color="#80000000"    android:width="2dp"></stroke>    <stroke android:color="#D3D3D3"></stroke>    <size android:width="60dp"        android:height="80dp"></size></shape>
查看完整描述

2 回答

?
智慧大石

TA貢獻1946條經驗 獲得超3個贊

您不會更改 Java 代碼中與按鈕的 UI 相關的任何內容,所以不,這不是因為 Java 代碼。它與 XML 相關。

您的按鈕背景是一個名為“rounded_button”的可繪制對象,但您尚未發布該可繪制文件的內容。所以我們所能做的就是猜測rounded_button drawable是白色的嗎?


查看完整回答
反對 回復 2022-05-12
?
一只甜甜圈

TA貢獻1836條經驗 獲得超5個贊

您可以采取兩個快速步驟來使這項工作以您想要的方式進行:


首先,將視圖從 Button 更改為 TextView 并應用rounded-button.xml背景。這應該立即起作用。嘗試為按鈕設置背景有點棘手,如此處所示。


其次,我注意到您的rounded-button.xml文件沒有solid元素。實體元素允許您設置布局的背景。出于這個原因,我將您的一個元素更改stroke為一個元素(無論如何solid都不應該有兩個元素)。stroke您更新rounded_button.xml的代碼如下所示:


PS:不要忘記將您的視圖 activity_main.xml 從 Button 更改為 TextView!



<shape 

    xmlns:android="http://schemas.android.com/apk/res/android"

    android:shape="oval">


    <stroke android:color="#80000000"

        android:width="2dp">

    </stroke>


    <solid 

        android:color="#D3D3D3">

    </solid>


    <size 

        android:width="60dp"

        android:height="80dp">

    </size>


</shape>

我希望這有幫助??鞓肪幋a!


查看完整回答
反對 回復 2022-05-12
  • 2 回答
  • 0 關注
  • 149 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號