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

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

為什么視圖沒有更新?

為什么視圖沒有更新?

拉風(fēng)的咖菲貓 2022-06-15 15:44:51
我正在構(gòu)建一個具有 2 個片段容器并具有屏幕截圖功能的應(yīng)用程序。問題是每當(dāng) 2 個片段容器中的一個用另一個片段(已替換)更新并且我正在截屏?xí)r,它會顯示以前的片段而不是更新的片段。我getView().getRootView()在活動的另一個片段中使用來截取屏幕截圖。關(guān)于為什么會發(fā)生的任何建議?
查看完整描述

2 回答

?
神不在的星期二

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

請詳細(xì)說明問題或嘗試添加代碼。


如果您不使用 FrameLayout,請使用它。


添加 FrameLayout 的代碼:


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

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/apk/res-auto"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    tools:context=".MainActivity">


    <FrameLayout

        android:id="@+id/your_placeholder"

        android:layout_width="0dp"

        android:layout_height="0dp"

        app:layout_constraintBottom_toBottomOf="parent"

        app:layout_constraintEnd_toEndOf="parent"

        app:layout_constraintStart_toStartOf="parent"

        app:layout_constraintTop_toTopOf="parent"></FrameLayout>


</android.support.constraint.ConstraintLayout>

要添加或替換新片段,請使用 FragmentTransaction。


// Code inside the onCreate method

getSupportFragmentManager().beginTransaction()

               .replace(R.id.your_placeholder, new TheOtherFragment())

               .commit();

拍攝屏幕截圖:


View view = findViewById(R.id.your_placeholder);

view.setDrawingCacheEnabled(true);

view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);

Bitmap screenshot = Bitmap.createBitmap(view.getDrawingCache());

view.setDrawingCacheEnabled(false);


查看完整回答
反對 回復(fù) 2022-06-15
?
犯罪嫌疑人X

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

拍攝屏幕截圖:


View view = findViewById(R.id.id_of_constraintLayout); 

// Here you assign the view Variable to the id of the View hosting all your Views. 


view.setDrawingCacheEnabled(true);

view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);


Bitmap screenshot = Bitmap.createBitmap(view.getDrawingCache());

view.setDrawingCacheEnabled(false);


查看完整回答
反對 回復(fù) 2022-06-15
  • 2 回答
  • 0 關(guān)注
  • 104 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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