當前位置: 首頁>>代碼示例>>Java>>正文


Java ViewGroup.findViewWithTag方法代碼示例

本文整理匯總了Java中android.view.ViewGroup.findViewWithTag方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewGroup.findViewWithTag方法的具體用法?Java ViewGroup.findViewWithTag怎麽用?Java ViewGroup.findViewWithTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.ViewGroup的用法示例。


在下文中一共展示了ViewGroup.findViewWithTag方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setSelected

import android.view.ViewGroup; //導入方法依賴的package包/類
@Test
public void setSelected() throws Exception {
    View pageView1 = mock(View.class, withSettings().extraInterfaces(PageView.class));
    View pageView2 = mock(View.class, withSettings().extraInterfaces(PageView.class));

    List<Page> pages = ImmutableList.of(
            new Page("page1", R.drawable.ic_share, "page1", (context, overlayCallback) -> pageView1),
            new Page("page2", R.drawable.ic_share, "page2", (context, overlayCallback) -> pageView2)
    );

    view.displayPages(pages, pages.get(0), false);

    ViewGroup iconHolder = view.findViewById(R.id.tab_icons_holder);

    Page selectedPage = pages.get(1);
    view.setSelected(selectedPage);
    for (int i = 0; i < iconHolder.getChildCount(); i++) {
        View child = iconHolder.getChildAt(i);
        assertTrue(child.isSelected() == ObjectUtil.equals(child.getTag(), selectedPage.getId()));
    }
    View selectedView = iconHolder.findViewWithTag(selectedPage.getId());
    assertEquals(selectedPage.getId(), selectedView.getTag());
}
 
開發者ID:roshakorost,項目名稱:Phial,代碼行數:24,代碼來源:ExpandedViewTest.java

示例2: removeFakeStatusBarViewIfExist

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * use reserved order to remove is more quickly.
 */
private static void removeFakeStatusBarViewIfExist(Activity activity) {
    Window window = activity.getWindow();
    ViewGroup mDecorView = (ViewGroup) window.getDecorView();

    View fakeView = mDecorView.findViewWithTag(TAG_FAKE_STATUS_BAR_VIEW);
    if (fakeView != null) {
        mDecorView.removeView(fakeView);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:StatusBarCompatKitKat.java

示例3: setColor

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * 設置狀態欄顏色
 *
 * @param activity       需要設置的activity
 * @param color          狀態欄顏色值
 * @param statusBarAlpha 狀態欄透明度
 */

public static void setColor(Activity activity, @ColorInt int color, @IntRange(from = 0, to = 255) int statusBarAlpha) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        activity.getWindow().setStatusBarColor(calculateStatusColor(color, statusBarAlpha));
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
        View fakeStatusBarView = decorView.findViewWithTag(FAKE_STATUS_BAR_VIEW_TAG);
        if (fakeStatusBarView != null) {
            if (fakeStatusBarView.getVisibility() == View.GONE) {
                fakeStatusBarView.setVisibility(View.VISIBLE);
            }
            fakeStatusBarView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
        } else {
            decorView.addView(createStatusBarView(activity, color, statusBarAlpha));
        }
        setRootView(activity);
    }
}
 
開發者ID:hoangkien0705,項目名稱:Android-UtilCode,代碼行數:29,代碼來源:BarUtils.java

示例4: setColorDiff

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * 設置狀態欄顏色(5.0以下無半透明效果,不建議使用)
 *
 * @param activity 需要設置的 activity
 * @param color    狀態欄顏色值
 */
@Deprecated
public static void setColorDiff(Activity activity, @ColorInt int color) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        return;
    }
    transparentStatusBar(activity);
    ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
    // 移除半透明矩形,以免疊加
    View fakeStatusBarView = contentView.findViewWithTag(FAKE_STATUS_BAR_VIEW_TAG);
    if (fakeStatusBarView != null) {
        if (fakeStatusBarView.getVisibility() == View.GONE) {
            fakeStatusBarView.setVisibility(View.VISIBLE);
        }
        fakeStatusBarView.setBackgroundColor(color);
    } else {
        contentView.addView(createStatusBarView(activity, color));
    }
    setRootView(activity);
}
 
開發者ID:hoangkien0705,項目名稱:Android-UtilCode,代碼行數:26,代碼來源:BarUtils.java

示例5: setColorForDrawerLayoutDiff

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * 為DrawerLayout 布局設置狀態欄變色(5.0以下無半透明效果,不建議使用)
 *
 * @param activity     需要設置的activity
 * @param drawerLayout DrawerLayout
 * @param color        狀態欄顏色值
 */
@Deprecated
public static void setColorForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        // 生成一個狀態欄大小的矩形
        ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
        View fakeStatusBarView = contentLayout.findViewWithTag(FAKE_STATUS_BAR_VIEW_TAG);
        if (fakeStatusBarView != null) {
            if (fakeStatusBarView.getVisibility() == View.GONE) {
                fakeStatusBarView.setVisibility(View.VISIBLE);
            }
            fakeStatusBarView.setBackgroundColor(calculateStatusColor(color, DEFAULT_STATUS_BAR_ALPHA));
        } else {
            // 添加 statusBarView 到布局中
            contentLayout.addView(createStatusBarView(activity, color), 0);
        }
        // 內容布局不是 LinearLayout 時,設置padding top
        if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
            contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
        }
        // 設置屬性
        setDrawerLayoutProperty(drawerLayout, contentLayout);
    }
}
 
開發者ID:pan2yong22,項目名稱:AndroidUtilCode-master,代碼行數:32,代碼來源:BarUtils.java

示例6: addStatusBarAlpha

import android.view.ViewGroup; //導入方法依賴的package包/類
private static void addStatusBarAlpha(final Activity activity, final int alpha, boolean isDecor) {
    ViewGroup parent = isDecor ?
            (ViewGroup) activity.getWindow().getDecorView() :
            (ViewGroup) activity.findViewById(android.R.id.content);
    View fakeStatusBarView = parent.findViewWithTag(TAG_ALPHA);
    if (fakeStatusBarView != null) {
        if (fakeStatusBarView.getVisibility() == View.GONE) {
            fakeStatusBarView.setVisibility(View.VISIBLE);
        }
        fakeStatusBarView.setBackgroundColor(Color.argb(alpha, 0, 0, 0));
    } else {
        parent.addView(createAlphaStatusBarView(parent.getContext(), alpha));
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:BarUtils.java

示例7: enable

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * Re-enables a view. This will remove the view added
 * @param viewGroup
 */
public static void enable(ViewGroup viewGroup){
    View view = viewGroup.findViewWithTag(DISABLE);
    if (view != null){
        viewGroup.removeView(view);
    }

}
 
開發者ID:kevinwang5658,項目名稱:backstack,代碼行數:12,代碼來源:Helper.java

示例8: removeFakeStatusBarViewIfExist

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * use reserved order to remove is more quickly.
 */
private static void removeFakeStatusBarViewIfExist(Activity activity) {
	Window window = activity.getWindow();
	ViewGroup decorview = (ViewGroup) window.getDecorView();

	View fakeView = decorview.findViewWithTag(TAG_FAKE_STATUS_BAR_VIEW);
	if (fakeView != null) {
		decorview.removeView(fakeView);
	}
}
 
開發者ID:MobClub,項目名稱:BBSSDK-for-Android,代碼行數:13,代碼來源:StatusBarCompatKitKat.java

示例9: hideFakeStatusBarView

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * 隱藏偽狀態欄 View
 *
 * @param activity 調用的 Activity
 */
public static void hideFakeStatusBarView(Activity activity) {
    ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    View fakeStatusBarView = decorView.findViewWithTag(FAKE_STATUS_BAR_VIEW_TAG);
    if (fakeStatusBarView != null) {
        fakeStatusBarView.setVisibility(View.GONE);
    }
    View fakeTranslucentView = decorView.findViewWithTag(FAKE_TRANSLUCENT_VIEW_TAG);
    if (fakeTranslucentView != null) {
        fakeTranslucentView.setVisibility(View.GONE);
    }
}
 
開發者ID:hoangkien0705,項目名稱:Android-UtilCode,代碼行數:17,代碼來源:BarUtils.java

示例10: clearPreviousSetting

import android.view.ViewGroup; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.KITKAT)
private static void clearPreviousSetting(Activity activity) {
    ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    View fakeStatusBarView = decorView.findViewWithTag(FAKE_STATUS_BAR_VIEW_TAG);
    if (fakeStatusBarView != null) {
        decorView.removeView(fakeStatusBarView);
        ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
        rootView.setPadding(0, 0, 0, 0);
    }
}
 
開發者ID:hoangkien0705,項目名稱:Android-UtilCode,代碼行數:11,代碼來源:BarUtils.java

示例11: removeNoticeView

import android.view.ViewGroup; //導入方法依賴的package包/類
private static void removeNoticeView(final ViewGroup parent, int tag) {
    View view = parent.findViewWithTag(tag + parent.hashCode());

    if (view != null) {
        parent.removeView(view);
        view.setTag(null);
    }
}
 
開發者ID:Pingsh,項目名稱:Mix,代碼行數:9,代碼來源:UIUtils.java

示例12: isVisible

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * Check is FancyShowCaseView visible
 *
 * @param activity should be used to find FancyShowCaseView inside it
 */
public static Boolean isVisible(@NonNull Activity activity) {
    ViewGroup androidContent = (ViewGroup) activity.findViewById(android.R.id.content);
    ViewGroup mRoot = (ViewGroup) androidContent.getParent().getParent();
    FancyShowCaseView mContainer = (FancyShowCaseView) mRoot.findViewWithTag(CONTAINER_TAG);
    return mContainer != null;
}
 
開發者ID:faruktoptas,項目名稱:FancyShowCaseView,代碼行數:12,代碼來源:FancyShowCaseView.java

示例13: hideCurrent

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * Hide  FancyShowCaseView
 *
 * @param activity should be used to hide FancyShowCaseView inside it
 */
public static void hideCurrent(@NonNull Activity activity) {
    ViewGroup androidContent = (ViewGroup) activity.findViewById(android.R.id.content);
    ViewGroup mRoot = (ViewGroup) androidContent.getParent().getParent();
    FancyShowCaseView mContainer = (FancyShowCaseView) mRoot.findViewWithTag(CONTAINER_TAG);
    mContainer.hide();
}
 
開發者ID:faruktoptas,項目名稱:FancyShowCaseView,代碼行數:12,代碼來源:FancyShowCaseView.java

示例14: delete

import android.view.ViewGroup; //導入方法依賴的package包/類
public static void delete(ViewGroup target) {
    View view = target.findViewWithTag(TAG);
    if (view != null) {
        target.removeView(view);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:7,代碼來源:Blurry.java

示例15: hideAlphaView

import android.view.ViewGroup; //導入方法依賴的package包/類
private static void hideAlphaView(final Activity activity) {
    ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    View fakeStatusBarView = decorView.findViewWithTag(TAG_ALPHA);
    if (fakeStatusBarView == null) return;
    fakeStatusBarView.setVisibility(View.GONE);
}
 
開發者ID:Wilshion,項目名稱:HeadlineNews,代碼行數:7,代碼來源:BarUtils.java


注:本文中的android.view.ViewGroup.findViewWithTag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。