【问题标题】:How to decrease/Increase the Transparency of Layout not Views如何减少/增加布局而不是视图的透明度
【发布时间】:2013-02-05 04:46:36
【问题描述】:

我想要这个。注意显示文本(即说明)的透明层。 还要检查背景一个木制的背景。

我试过了,但没有得到想要的结果

 <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_margin="10dp"
                android:alpha="0.75" >

                <TextView
                    android:id="@+android:id/txtInstructions"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@+android:id/relImagesLogo"
                    android:layout_centerInParent="true"
                    android:lineSpacingMultiplier="1.5"
                    android:text="Lorem Ipsum is simply dummy text of 

                    the printing and typesetting industry. Lorem Ipsum has been the 

                    industry&apos;s standard dummy text ever since the 1500s, when an                      unknown 

                    printer took a galley of type and scrambled it to make a type specimen 

                    book. It has survived not only five centuries, but also the leap into 

                    electronic typesetting, remaining essentially unchanged. It was popularised "
                    android:textColor="@android:color/white"
                    android:textSize="14sp" />

                <RelativeLayout
                    android:id="@+android:id/relImagesLogo"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:layout_centerHorizontal="true" >

                    <ImageView
                        android:id="@+android:id/imgInstructionLogo"
                        android:layout_width="30dp"
                        android:layout_height="30dp"
                        android:layout_marginRight="2dp"
                        android:src="@drawable/instruction_icon" />

                    <ImageView
                        android:id="@+android:id/imgInstructionHeading"
                        android:layout_width="wrap_content"
                        android:layout_height="30dp"
                        android:layout_centerVertical="true"
                        android:layout_toRightOf="@+android:id/imgInstructionLogo"
                        android:src="@drawable/instruction_heading" />
                </RelativeLayout>
            </RelativeLayout>

请注意,android:alpha="0.75" 正在使我的所有视图对 0.75 级透明。我不想要这个。我只想要那个透明层。

知道我得到了这个结果

【问题讨论】:

  • 您需要创建一个可绘制的形状并将其设置为您的布局组的背景资源

标签: android android-layout android-relativelayout xml-layout


【解决方案1】:

xxyyyyyy

xx 是您的透明度级别,y 是您的颜色。

xx 最大值是:ff // 这是完全可见的

xx min value is : 00 // 这是完全不可见的

编辑:顺便说一句,我们在 android:background="xxyyyyyy" 中使用这些代码

【讨论】:

    【解决方案2】:


    尝试:

        <RelativeLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_margin="10dp"
            android:background="#66FF0000" >
    

    你可以看到: android:color="#66FF0000" // 部分透明的红色

    我建议您检查以下信息: Android set alpha opacity for a custom view

    Android and setting alpha for (image) view alpha

    【讨论】:

    • 谢谢。它帮助了我,但我做了这个 android:background="##66708090"。这给了我黑色透明的颜色层
    【解决方案3】:

    您需要将最外层布局的背景设置为可绘制的木材。 并将文本视图的背景设置为透明颜色。 试试这个:

    <RelativeLayout xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center_horizontal"
    android:background="#FF008833" >
    
    <TextView
        android:id="@+android:id/txtInstructions"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="30dp"
        android:layout_below="@+android:id/relImagesLogo"
        android:layout_centerInParent="true"
        android:lineSpacingMultiplier="1.5"
        android:background="#BB000000"
    
        android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry&apos;s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised "
        android:textColor="@android:color/white"
        android:textSize="14sp" />
    </RelativeLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-12-01
      • 2017-06-20
      • 1970-01-01
      • 2015-11-27
      • 1970-01-01
      • 1970-01-01
      • 2017-07-01
      相关资源
      最近更新 更多