簡體   English   中英

在Android中具有透明背景的圖像問題

[英]Issue with image having transparent background in Android

我正在創建一個帶有圓角背景圖像的自定義對話框。 我使用自定義樣式刪除了白色邊框,但它顯示為好像我的圖像后面有一個相同大小的黑色矩形,如下所示(對話框的背景圖像是棕色的):

在此輸入圖像描述

如何用圓角保持圖像的透明背景?


我的對話框的布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/confirmation"
android:orientation="vertical"
android:background="@drawable/dialog_background"
android:layout_width="279dp"
android:layout_height="130dp"   
>
...

我通過在我的對話框中應用以下樣式來刪除白色邊框:

<style
name="Theme_Dialog_Translucent"
parent="android:Theme.Dialog">
<item name="android:windowBackground">@null</item>
</style>

我的CustomDialog類是:

public class CustomDialog extends Dialog implements OnClickListener {
Button okButton;

public CustomDialog(Context context) {
    // Custom style to remove dialog border - corners black though :(
    super(context, R.style.Theme_Dialog_Translucent);
    // 'Window.FEATURE_NO_TITLE' - Used to hide the title
    requestWindowFeature(Window.FEATURE_NO_TITLE);      
    setContentView(R.layout.custom_dialog);
    okButton = (Button) findViewById(R.id.button_ok);
    okButton.setOnClickListener(this);
}

...

}

問題出在windowBackground屬性中試試這個

<item name="android:windowBackground">#00000000</item>

這將使窗口背景透明。

我希望能解決這個問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM