Android Transparent TextView?

Po Prostu, Jak zrobić TextView przezroczystym? (nie pełna przejrzystość)

Przeszukałem dokumenty i układ stosu i nie mogłem go znaleźć? Chyba jest coś takiego.

Dzięki.

UPDATE

To jest kod XML:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_horizontal"
    android:orientation="vertical"
    android:background="@drawable/background">

    <ImageView 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/header"
    android:src="@drawable/logo1"
    />
    <ListView android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:paddingRight="5dp"
    android:scrollbarStyle="outsideOverlay"
    android:cacheColorHint="#00000000" />


    <TextView
    android:id="@+id/footer"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="25sp"
    android:singleLine="true"
    android:background="#07000000"
    android:textColor="#FFFFFF"
    android:text="rrrrr" />

 </LinearLayout>

Chcę stopkę TextView to be transparent so that the ListView items can be seen while scrolling

Author: iTurki, 2011-07-07

12 answers

Proszę spróbować tego kawałka kodu..

<TextView 
   android:id="@+id/txtview1"
   android:layout_width="wrap_content" 
   android:background="@drawable/bg_task" 
   android:layout_height="wrap_content" 
   android:textSize="14sp" 
   android:singleLine="true"
   android:textColor="#FFFFFF" />

Używany obraz tła jako przezroczysty, więc można to rozwiązać.

Lub

android:background="#07000000"

Lub

Proszę spróbować poniżej ...

<?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:gravity="center_horizontal" android:orientation="vertical"
    android:background="@drawable/main_bg">
    <ImageView android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:id="@+id/header"
        android:src="@drawable/btn_complete" />
    <RelativeLayout android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <ListView android:id="@+id/list" android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:layout_weight="1"
            android:paddingRight="5dp" android:scrollbarStyle="outsideOverlay"
            android:cacheColorHint="#00000000" />
        <TextView android:id="@+id/footer" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:textSize="25sp"
            android:singleLine="true" android:background="#07000000"
            android:textColor="#FFFFFF" android:text="rrrrr"
            android:layout_centerInParent="true"
            android:layout_alignParentBottom="true" />
    </RelativeLayout>
</LinearLayout>
 38
Author: Nikhil,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-01-05 08:44:37

Zobacz dokumentacja zasobów kolorów Androida w celach informacyjnych.

Zasadniczo masz możliwość ustawienia przezroczystości (nieprzezroczystości) i koloru bezpośrednio w układzie lub za pomocą odniesień do zasobów.

Wartość szesnastkowa, na którą ją Ustawiłeś, składa się z 3 do 4 części:

  • Alfa (nieprzezroczystość), będę się odnosił do tego jako aa

  • Czerwony, będę się nazywał rr

  • Zielony, będę się odnosił do niego jako gg

  • Niebieski, będę się nazywał bb

Bez wartości alfa (przezroczystość):

android:background="#rrggbb"

Lub jako źródło:

<color name="my_color">#rrggbb</color>

Z {[11] } wartością Alfa (przezroczystość):

android:background="#aarrggbb"

Lub jako źródło:

<color name="my_color">#aarrggbb</color>

Wartość alfa dla pełnej przezroczystości wynosi 00 a wartość alfa dla No przezroczystości to FF.

Zobacz pełny zakres wartości szesnastkowych poniżej:

100% — FF
 95% — F2
 90% — E6
 85% — D9
 80% — CC
 75% — BF
 70% — B3
 65% — A6
 60% — 99
 55% — 8C
 50% — 80
 45% — 73
 40% — 66
 35% — 59
 30% — 4D
 25% — 40
 20% — 33
 15% — 26
 10% — 1A
  5% — 0D
  0% — 00

Możesz eksperymentuj z wartościami pomiędzy nimi.

 90
Author: Marmoy,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-07-27 11:45:07

Poniżej kod dla czarnego:-

<color name="black">#000000</color>

Teraz, jeśli chcę użyć nieprzezroczystości, możesz użyć poniższego kodu: -

 <color name="black">#99000000</color> 

I poniżej dla kodu nieprzezroczystości:-

Wartości Nieprzezroczystości Sześciokątnej

100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
75% — BF
70% — B3
65% — A6
60% — 99
55% — 8C
50% — 80
45% — 73
40% — 66
35% — 59
30% — 4D
25% — 40
20% — 33
15% — 26
10% — 1A
5% — 0D
0% — 00

Refer zrozumienie kolorów na Androidzie (sześć znaków)

 43
Author: duggu,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 12:18:01

Użyj tego:

android:background="@android:color/transparent"
 22
Author: darvinda,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-12-02 11:16:08

<TextView android:alpha="0.3" ..., Na przykład.

 8
Author: Peter V,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-11-26 13:54:19

Aby ustawić programowo:

setBackgroundColor(Color.TRANSPARENT);
Dla mnie też musiałem ustawić kolor.Przezroczysty w układzie nadrzędnym.
 5
Author: Aaron,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-07-03 23:44:35

Chociaż ta odpowiedź jest bardzo późno, ale może pomóc innym programistom, więc zamieszczam ją tutaj.

Odpowiedzi powyżej pokazujące tylko jak ustawić przezroczyste tło dla TextView. Możemy osiągnąć przezroczysty Textview backcgorund na dwa sposoby:

  1. ustawiając kod krycia, taki jak #88000000 w Androidzie: atrybut background
  2. przez ustawienie atrybutu android: alpha= " 0.5 " do TextView

Drugie podejście jest lepsze, ponieważ daje elastyczność ustawiania tła z inny kolor, a następnie ustawienie ustawienia krycia widżetu za pomocą Androida: alpha="0.2"

Przykład

<TextView
        android:id="@+id/tv_name"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/black"
        android:alpha="0.3"
        android:textColor="@color/white"
        android:textStyle="bold"/>
 5
Author: Geek,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-08-24 13:41:44

Jeśli szukasz czegoś takiego jak widok tekstu na obrazie w aplikacji pulse, zrób to

 android:background="#88000000"
android:textColor="#ffffff"
 3
Author: Slartibartfast,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-02-06 09:28:21

Spróbuj ustawić android:background="#00000000" W TextView. Ustawienie Alfy koloru 00 spowoduje, że tło będzie przezroczyste.

Nie próbowałem tego, ale powinno zadziałać.
 1
Author: Udayan,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-07-07 10:17:17

Wszyscy odpowiadają poprawnie na temat przejrzystości, ale nie słuchają tego, czego facet potrzebuje w odniesieniu do listy przewijającej się za stopką.

Musisz zrobić stopkę częścią swojego ListView. W tej chwili lista nie będzie przewijać się z tyłu, ponieważ układ widoku listy nie znajduje się za stopką z przezroczystością. Wykonaj RelativeLayout i ustaw przezroczystość na dole.

 1
Author: Alex Robęrts,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-03-31 16:30:14

W przypadku, gdy ktoś chce to zrobić w sposób programowania! Wykonaj następujące czynności: Zaktualizuj tym plik koloru w folderze wartości.

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="transparent">#00ffffff</color> <!--This is the transparency line-->
</resources>

Następnie wywołaj program przezroczystości

your_textview.setBackgroundResource(R.color.transparent);
 1
Author: Adepoju-Conde Adesegun Chris.,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-04-24 16:22:30

Witam proszę spróbować z poniższym kodem koloru jako tłem textview.

android:background="#20535252"

 0
Author: Chirag,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-07-07 10:48:39