0

Android LinearLayoutの背景の透明度を変更したいと思います。ここでは、activity_view_full_screen_image.xmlのandroid:alpha = "0.4"の値を変更しようとしました。しかし、レイアウトの透過性の代わりに、PhotoView透明度などのレイアウトコンテンツが変更されます。この問題は迅速な対応で解決していただき、誠にありがとうございます。ここでAndroid Linear Layout Background Transparency

は私のコードです:

ViewFullScreenImage.java

import android.graphics.Color; 
import android.net.Uri; 
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 
import android.widget.LinearLayout; 

import com.github.chrisbanes.photoview.PhotoView; 
import com.squareup.picasso.Picasso; 

import java.io.InputStream; 

public class ViewFullScreenImage extends AppCompatActivity { 


    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_view_full_screen_image); 
     loadImage(); 
    } 

    public void loadImage(){ 

     Uri imageUrl = Uri.parse("http://www.ucdmc.ucdavis.edu/hr/images/body/Health-Welness-Businesses.jpg"); 

     PhotoView photoView = (PhotoView) findViewById(R.id.photo_view); 
     Picasso.with(this).load(imageUrl).into(photoView); 
    } 
} 

backgrounを設定

activity_full_screen_image.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_view_full_screen_image" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:alpha="0.4" 
    tools:context="com.example.theace.fullscreen.ViewFullScreenImage"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/my_layout" 
     android:orientation="vertical" 
     > 

     <com.github.chrisbanes.photoview.PhotoView 
      android:id="@+id/photo_view" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"/> 


    </LinearLayout> 



</LinearLayout> 

答えて

0

d色をこのようなものにする

android:background="#88FFFFFF" 

色はAARRGGBB形式です。最初の2桁は背景のアルファを制御するために使用できます。

0

これは、親レイアウトのandroid:background名前空間に依存します。 レイアウトにandroid:alpha="0.4"を設定する代わりに、 背景色を設定してください!例えば

android:background="#40ffffff"

フロント2桁はアルファ値です。

1

アンドロイド:アルファ=「0.4」

あなたがandroid:alphaと今ではなく、すなわち半透明色であることをその背景を設定すると、全体のビューのアルファを設定しないでください:

android:background="#AARRGGBB" 
AA色のアルファを表し

FFが完全に不透明であることと、そして00は完全に透明である):

android:background="#80FF0000" 

は、50%透明赤を与える。

文書:https://developer.android.com/guide/topics/resources/more-resources.html#Color