Android PNG背景透明图像

发布于 2025-01-02 00:10:01 字数 1756 浏览 4 评论 0原文

我在更改按钮背景图像时遇到问题。 所以我有 2 张图像(png-24 透明背景)。 图像是一个简单的圆圈和相同的圆圈,但带有一些外发光)。 我有以下代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ticketing_row_topup"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@layout/pressed_topup_button"
    android:orientation="horizontal" >

<TextView
    android:id="@+id/topup_name"
    android:layout_width="60dp"
    android:layout_height="fill_parent"
    android:gravity="center_vertical|right"
    android:paddingRight="5dip"
    android:paddingTop="22dip"
    android:text="€"
    android:textColor="@color/black"
    android:textSize="35sp"
    android:textStyle="bold" />

<TextView
    android:id="@+id/topup_display_amount"
    android:layout_width="90dp"
    android:layout_height="match_parent"
    android:gravity="center_vertical|left"
    android:textSize="65sp"
    android:textColor="#0d457f"
    android:textStyle="bold" />
</LinearLayout>

和 Pressed_topup_button.xml

 <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:state_enabled="false">
    <item android:state_pressed="true" android:state_enabled="true" android:drawable="@drawable/button_topup_glow" /> 
    <item android:state_focused="true" android:state_enabled="true" android:drawable="@drawable/button_topup" />
    <item android:state_enabled="true" android:drawable="@drawable/button_topup" /> 
</selector>

LinearLayout 用于在每个单元格中填充 GridView。 当我单击单元格时,行为是正确的(显示发光),但图像的一角(假设是透明的)也会显示黄色。我该如何解决这个问题? 谢谢

I have a problem with changing button background image.
So i have 2 images (png-24 transparent background).
Images are a simple circle and the same circle but with some outerglow ).
I have the following code

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ticketing_row_topup"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@layout/pressed_topup_button"
    android:orientation="horizontal" >

<TextView
    android:id="@+id/topup_name"
    android:layout_width="60dp"
    android:layout_height="fill_parent"
    android:gravity="center_vertical|right"
    android:paddingRight="5dip"
    android:paddingTop="22dip"
    android:text="€"
    android:textColor="@color/black"
    android:textSize="35sp"
    android:textStyle="bold" />

<TextView
    android:id="@+id/topup_display_amount"
    android:layout_width="90dp"
    android:layout_height="match_parent"
    android:gravity="center_vertical|left"
    android:textSize="65sp"
    android:textColor="#0d457f"
    android:textStyle="bold" />
</LinearLayout>

And the pressed_topup_button.xml

 <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:state_enabled="false">
    <item android:state_pressed="true" android:state_enabled="true" android:drawable="@drawable/button_topup_glow" /> 
    <item android:state_focused="true" android:state_enabled="true" android:drawable="@drawable/button_topup" />
    <item android:state_enabled="true" android:drawable="@drawable/button_topup" /> 
</selector>

The LinearLayout is used to populate a GridView in each cell.
When i click the cell the behavior is correct (the glow is displayed) but also a yellow color is display on the corner of the image (where suppose to be transparent). How can i fix that?
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

§普罗旺斯的薰衣草 2025-01-09 00:10:01

您需要添加

 android:listSelector="@android:color/transparent"

到 GridView 声明中。

看看这个:
Android:禁用 GridView 中的突出显示

You need to add

 android:listSelector="@android:color/transparent"

to your GridView declaration.

See this:
Android: Disable highlighting in GridView

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文