我想更改我的Android LinearLayout背景透明度。在這裏我試圖改變activity_view_full_screen_image.xml中的android:alpha =「0.4」值。但是佈局內容(如PhotoView透明度)會改變,而不是佈局透明度。請快速解答此問題,敬請諒解。Android線性佈局背景透明度
這裏是我的代碼:
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);
}
}
和
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>