繁体   English   中英

如何在翻译动画android期间设置透明背景?

[英]How to set transparent background during translate animation android?

我有以下问题。 我有一个TableLayout和两个TableRows。 两个TableRows都包含两个ImageButton。 单击一个按钮时,我想淡出其他三个按钮并翻转屏幕中央的单击按钮。 当它被翻译时,顶部或下半部分消失,就像它被另一个表格行隐藏一样。 我试图设置表行的透明背景,设置alpha = 0,更改布局,我也尝试使用ScaleAnimation,但问题并没有消失。 我怎么能显示消失的一半? 我还发布了布局代码和带有问题的屏幕链接。

http://it.tinypic.com/r/1zejhir/5

`

<RelativeLayout
    android:id="@+id/l34"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:layout_alignParentTop="true">
        <ImageButton
            android:id="@+id/four"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="top|right"
            android:src="@drawable/unor"
            android:alpha="0"
            android:onClick="translate"
            android:layout_alignParentLeft="true" />

        <ImageButton
            android:id="@+id/three"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="top|left"
            android:src="@drawable/unor"
            android:alpha="0"
            android:onClick="translate"
            android:layout_alignParentRight="true" />
</RelativeLayout>

<RelativeLayout
    android:id="@+id/l12"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentBottom="true">
        <ImageButton
            android:id="@+id/one"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="top|right"
            android:src="@drawable/unor"
            android:alpha="0"
            android:onClick="translate"
            android:layout_alignParentLeft="true" />

        <ImageButton
            android:id="@+id/two"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="top|left"
            android:src="@drawable/unor"
            android:alpha="0"
            android:onClick="translate"
            android:layout_alignParentRight="true" />
</RelativeLayout>

</RelativeLayout>

`

使透明

java code-> imagebtn.setBackgroundColor(Color.TRANSPARENT);

xml - > android:background="@android:color/transparent"

问题是你想使用来自其他视图组的“空间”,你的视图被绑定到托管视图组 (例如tablerow)。 它与透明背景无关。 解决方案是让一个视图组包含所有图标 例如,使用RelativeLayout。

使用以下代码修改values文件夹中的styles.xml文件资源

<item name="android:windowIsTranslucent">true</item>

<item name="android:windowBackground">@android:color/transparent</item>

<item name="android:windowContentOverlay">@null</item>

<item name="android:windowNoTitle">true</item>

<item name="android:windowIsFloating">true</item>

<item name="android:backgroundDimEnabled">false</item>

在manifest.xml文件中,将以下步骤添加到哪个活动使您变为透明。

android:theme="@style/Theme.Transparent"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM