简体   繁体   English

如何制作透明布局?

[英]How to make a transparent layout?

I have following code for main layout: 我有以下主要布局代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/layout"
    android:gravity="center"
    android:background="#00000000"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:background="#FFFFFF" />

</LinearLayout>

I need that the LinearLayout will be transparent. 我需要LinearLayout是透明的。 I thought that I can do it using the alpha setting in a background attibute, but it doesn't work. 我以为我可以在背景装饰中使用alpha设置来做到这一点,但这是行不通的。 Please, tell me - I need that my application will be empty and has a white rectangle on the center of a screen. 请告诉我-我需要我的应用程序为空,并且在屏幕中央有一个白色矩形。

You want the activity to be transparent? 您希望活动透明吗? Try using this theme in your activity tag (in the manifest file): @android:style/Theme.Translucent 尝试在活动标签(清单文件中)中使用此主题: @android:style/Theme.Translucent

For other possible ways, ie child theme see the following answers: 对于其他可能的方式,例如子主题,请参见以下答案:

Activity should be transparent, but has black background 活动应透明,但背景为黑色

How do I create a transparent Activity on Android? 如何在Android上创建透明的活动?

how to make activities transparent 如何使活动透明

在xml文件中使用以下行:

<Linearlayout android:background="@android:color/transparent"/>

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

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