我想更改我的 Android LinearLayout 背景透明度。在这里,我尝试更改 activity_view_full_screen_image.xml 中的 android:alpha="0.4" 值。但是像 PhotoView 透明度这样的布局内容是改变的,而不是布局透明度。
这是我的代码:
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>