第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Android Studio 和 Firebase:全屏顯示 ImageView

Android Studio 和 Firebase:全屏顯示 ImageView

繁星coding 2023-06-14 14:57:07
我有一個(gè)屏幕顯示我的電影名稱及其在我的 Firebase 中的圖片。我的數(shù)據(jù)庫結(jié)構(gòu)是這樣的。name是我的電影名稱的字符串。profilePic是包含來自 Firebase 存儲(chǔ)的圖片鏈接的字符串。我想要的是,當(dāng)我點(diǎn)擊列出的任何圖片時(shí),我想在另一個(gè)更大尺寸的活動(dòng)中顯示它(比如打開某人的 WhatsApp 或 Facebook 個(gè)人資料圖片)這些是我的課程,效果很好。我怎樣才能做到這一點(diǎn)?Movies.javapackage com.example.XXXX;import android.content.Intent;import android.support.annotation.NonNull;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.support.v7.widget.LinearLayoutManager;import android.support.v7.widget.RecyclerView;import android.view.View;import android.widget.ArrayAdapter;import android.widget.ImageButton;import android.widget.ListView;import android.widget.Toast;import com.google.firebase.auth.FirebaseAuth;import com.google.firebase.database.ChildEventListener;import com.google.firebase.database.DataSnapshot;import com.google.firebase.database.DatabaseError;import com.google.firebase.database.DatabaseReference;import com.google.firebase.database.FirebaseDatabase;import com.google.firebase.database.ValueEventListener;import java.util.ArrayList;public class Movies extends AppCompatActivity {? ? DatabaseReference reference;? ? RecyclerView recyclerView;? ? ArrayList<Profile> list;? ? MyAdapter adapter;? ? private String message;? ? @Override? ? protected void onCreate(Bundle savedInstanceState) {? ? ? ? super.onCreate(savedInstanceState);? ? ? ? setContentView(R.layout.activity_movies);? ? ? ? recyclerView = (RecyclerView) findViewById(R.id.recyclerview_films);? ? ? ? recyclerView.setLayoutManager(new LinearLayoutManager(this));
查看完整描述

3 回答

?
胡子哥哥

TA貢獻(xiàn)1825條經(jīng)驗(yàn) 獲得超6個(gè)贊

將視圖持有者修改為


class MyViewHolder extends RecyclerView.ViewHolder

{

        TextView name;

        ImageView profilePic;

        View mView;

        public MyViewHolder(@NonNull View itemView) 

    {

            super(itemView);

            mView = itemView;

            name = (TextView) itemView.findViewById(R.id.film_name);

            profilePic = (ImageView) itemView.findViewById(R.id.filmProfile);

        }

    }

在適配器中實(shí)現(xiàn)視圖持有者的點(diǎn)擊偵聽器,然后使用圖像 url 啟動(dòng)活動(dòng)。


@Override

public void onBindViewHolder(@NonNull MyViewHolder myViewHolder, int i) {

    myViewHolder.name.setText(profiles.get(i).getName());

    Picasso.get().load(profiles.get(i).getProfilePic()).into(myViewHolder.profilePic);  

    mViewHolder.mView.setOnClickListener(new View.OnClickListener(){

        @Override

        public void onClick(View v) {

            startImageActivity(profiles.get(i).getProfilePic());

        }

    });

}

3.創(chuàng)建活動(dòng)并從所需尺寸的圖像視圖開始。


    void startImageActivity(String imgUrl)

    {

    Intent intent = new Intent(context,ViewImage.class);

    intent.putExtra("profilePic",imgUrl);

    context.startActivity(intent);

    }

或者在外部應(yīng)用程序中打開圖像嘗試


    void startImageActivity(String imgUrl)

    {

   Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(imgUrl));             

   context.startActivity(intent);

    }


查看完整回答
反對 回復(fù) 2023-06-14
?
MM們

TA貢獻(xiàn)1886條經(jīng)驗(yàn) 獲得超2個(gè)贊

調(diào)整位圖大?。?/strong>

Bitmap resizedBitmap = Bitmap.createScaledBitmap(
    originalBitmap, newWidth, newHeight, false);


查看完整回答
反對 回復(fù) 2023-06-14
?
MMTTMM

TA貢獻(xiàn)1869條經(jīng)驗(yàn) 獲得超4個(gè)贊

您可以使用此庫進(jìn)行放大和縮小功能,

你需要在你的項(xiàng)目中添加這個(gè) gradle

實(shí)施 'com.otaliastudios:zoomlayout:1.6.1'

檢查下面的示例布局

<?xml?version="1.0"?encoding="utf-8"?>

<LinearLayout

? ? android:layout_width="match_parent"

? ? android:layout_height="match_parent"

? ? android:background="@color/dark_grey"

? ? android:orientation="vertical"

? ? android:weightSum="13">



? ? <ImageView

? ? ? ? android:id="@+id/iv_cancel"

? ? ? ? android:layout_width="wrap_content"

? ? ? ? android:layout_height="wrap_content"

? ? ? ? android:layout_gravity="right"

? ? ? ? android:layout_margin="@dimen/margin_small"

? ? ? ? android:padding="@dimen/margin_small"

? ? ? ? android:src="@drawable/ic_skip" />



? ? <View

? ? ? ? android:layout_width="match_parent"

? ? ? ? android:layout_height="match_parent"

? ? ? ? android:layout_weight="6" />


? ? <com.otaliastudios.zoom.ZoomImageView

? ? ? ? android:id="@+id/zoom_image"

? ? ? ? android:layout_width="match_parent"

? ? ? ? android:layout_height="match_parent"

? ? ? ? android:layout_weight="2"

? ? ? ? android:scrollbars="vertical|horizontal"

? ? ? ? app:alignment="center"

? ? ? ? app:animationDuration="280"

? ? ? ? app:flingEnabled="true"

? ? ? ? app:horizontalPanEnabled="true"

? ? ? ? app:maxZoom="2.5"

? ? ? ? app:maxZoomType="zoom"

? ? ? ? app:minZoom="0.7"

? ? ? ? app:minZoomType="zoom"

? ? ? ? app:overPinchable="true"

? ? ? ? app:overScrollHorizontal="true"

? ? ? ? app:overScrollVertical="true"

? ? ? ? app:transformation="centerInside"

? ? ? ? app:transformationGravity="auto"

? ? ? ? app:verticalPanEnabled="true"

? ? ? ? app:zoomEnabled="true" />


? ? <View

? ? ? ? android:layout_width="match_parent"

? ? ? ? android:layout_height="match_parent"

? ? ? ? android:layout_weight="5" />

</LinearLayout>

在JAVA類中,您需要像下面這樣加載圖像,我正在使用 Glide 進(jìn)行圖像加載,如下所示


?GlideApp.with(this)

? ? ? ? ? ? ? ? ? ? .asBitmap()

? ? ? ? ? ? ? ? ? ? .load(YOUR_IMAGE_URL)

? ? ? ? ? ? ? ? ? ? .into(new SimpleTarget<Bitmap>() {

? ? ? ? ? ? ? ? ? ? ? ? @Override

? ? ? ? ? ? ? ? ? ? ? ? public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {

? ? ? ? ? ? ? ? ? ? ? ? ? ? YOUR_IMAGEVIEW.setImageBitmap(resource);

? ? ? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ? ? });

檢查ZoomActivity.java下面的演示目的


?public class ZoomActivity extends AppCompatActivity {



? ? @Override

? ? protected void onCreate(@Nullable Bundle savedInstanceState) {

? ? ? ? super.onCreate(savedInstanceState);


? ? ? ? this.requestWindowFeature(Window.FEATURE_NO_TITLE);

? ? ? ? this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);


? ? ? ? setContentView(R.layout.activity_zoom);


? ? ? //? ActivityZoomBinding mBinding = DataBindingUtil.setContentView(this, R.layout.activity_zoom);



? ? ? ? ImageView zoomImage = findViewById(R.id.zoom_image);



? ? ? ? ///GETTING INTENT DATA

? ? ? ? Intent intent = getIntent();

? ? ? ? if (intent.hasExtra("ZOOM_IMAGE")) {


? ? ? ? ? ? String imageUrl = intent.getStringExtra("ZOOM_IMAGE");


? ? ? ? ? ? GlideApp.with(this)

? ? ? ? ? ? ? ? ? ? .asBitmap()

? ? ? ? ? ? ? ? ? ? .load(imageUrl)

? ? ? ? ? ? ? ? ? ? .into(new SimpleTarget<Bitmap>() {

? ? ? ? ? ? ? ? ? ? ? ? @Override

? ? ? ? ? ? ? ? ? ? ? ? public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {

? ? ? ? ? ? ? ? ? ? ? ? ? ? zoomImage.setImageBitmap(resource);

? ? ? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ? ? });



? ? ? ? }



? ? }



}


查看完整回答
反對 回復(fù) 2023-06-14
  • 3 回答
  • 0 關(guān)注
  • 203 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號