2013-02-20 2 views
0

Я хочу это. Обратите внимание на прозрачный слой, на котором появляется текст (например, инструкции). также проверить фон деревянный фон.Как уменьшить/увеличить прозрачность макета, а не виды

enter image description here

я м попытался это, но не получили желаемых результатов

<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. Я не хочу этого. Я просто хочу этот прозрачный слой.

Право знать, я получаю этот результат

enter image description here

+0

Вам нужно создать форму, которая может быть выбрана, и установить ее как фоновый ресурс для вашей группы макета. – Pragnani

ответ

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" > 

Вы можете видеть, что: андроид: цвет = "# 66FF0000" // Частично прозрачный red

Я стараюсь вас проверить эту информацию: Android set alpha opacity for a custom view

Android and setting alpha for (image) view alpha

+0

Спасибо за это. это помогло мне, но я сделал этот андроид: background = "## 66708090". это дает мне черноватый прозрачный цветной слой –

2

Вы должны установить фон внешней компоновки для дерева Drawable. И установить фон текстового вида на прозрачный цвет. Попробуйте это:

<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> 
1

xxyyyyyy

хх ваш уровень прозрачности, и у являются цвет.

ого значение Макса: Ф.Ф. // это полностью прозрачен

ой мин значение: 00 // это полный невидимый

редактировать: Кстати, мы используем эту коду в Android: фон =» xxyyyyyy "