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


Java SlidingPaneLayout.addView方法代碼示例

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


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

示例1: onCreate

import android.support.v4.widget.SlidingPaneLayout; //導入方法依賴的package包/類
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  slidingPaneLayout = new SlidingPaneLayout(this);
  slidingPaneLayout.setId(android.R.id.primary);

  FrameLayout paneOne = new FrameLayout(this);
  LayoutParams paneOneParams = new LayoutParams(300, MATCH_PARENT);
  slidingPaneLayout.addView(paneOne, paneOneParams);

  FrameLayout paneTwo = new FrameLayout(this);
  paneTwo.setBackgroundColor(Color.WHITE);
  LayoutParams paneTwoParams = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
  paneTwoParams.leftMargin = 50;
  slidingPaneLayout.addView(paneTwo, paneTwoParams);


  setContentView(slidingPaneLayout);
}
 
開發者ID:JakeWharton,項目名稱:RxBinding,代碼行數:20,代碼來源:RxSlidingPaneLayoutTestActivity.java

示例2: initSwipeBackFinish

import android.support.v4.widget.SlidingPaneLayout; //導入方法依賴的package包/類
/**
 * 初始化滑動返回
 */
private void initSwipeBackFinish() {
    if (isSupportSwipeBack) {
        SlidingPaneLayout slidingPaneLayout = new SlidingPaneLayout(this);
        //通過反射改變mOverhangSize的值為0,這個mOverhangSize值為菜單到右邊屏幕的最短距離,默認
        //是32dp,現在給它改成0
        try {
            //屬性
            Field f_overHang = SlidingPaneLayout.class.getDeclaredField("mOverhangSize");
            f_overHang.setAccessible(true);
            f_overHang.set(slidingPaneLayout, 0);
        } catch (Exception e) {
            e.printStackTrace();
        }

        slidingPaneLayout.setPanelSlideListener(BaseActivityWithSlidingPaneLayout.this);
        slidingPaneLayout.setSliderFadeColor(getResources().getColor(android.R.color.transparent));
        //slidingPaneLayout.setLayoutParams(new SlidingPaneLayout.LayoutParams(100,SlidingPaneLayout.LayoutParams.MATCH_PARENT));
        View leftView = new View(this);
        leftView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        slidingPaneLayout.addView(leftView, 0);

        ViewGroup decor = (ViewGroup) getWindow().getDecorView();
        ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
        //decorChild.setBackgroundColor(getResources().getColor(android.R.color.white));
        decor.removeView(decorChild);
        decor.addView(slidingPaneLayout);
        slidingPaneLayout.addView(decorChild, 1);
    }
}
 
開發者ID:hkq325800,項目名稱:YellowNote,代碼行數:33,代碼來源:BaseActivityWithSlidingPaneLayout.java

示例3: initSwipeBackFinish

import android.support.v4.widget.SlidingPaneLayout; //導入方法依賴的package包/類
/**
 * 初始化滑動返回
 */
private void initSwipeBackFinish() {
    if (isSupportSwipeBack()) {
        SlidingPaneLayout slidingPaneLayout =  new SlidingPaneLayout(this);
        //通過反射改變mOverhangSize的值為0,這個mOverhangSize值為菜單到右邊屏幕的最短距離,默認
        //是32dp,現在給它改成0
        try {
            //屬性
            Field f_overHang = SlidingPaneLayout.class.getDeclaredField("mOverhangSize");
            f_overHang.setAccessible(true);
            f_overHang.set(slidingPaneLayout, 0);
        } catch (Exception e) {
            e.printStackTrace();
        }
        slidingPaneLayout.setPanelSlideListener(this);
        slidingPaneLayout.setSliderFadeColor(getResources().getColor(android.R.color.transparent));

        View leftView = new View(this);
        leftView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        slidingPaneLayout.addView(leftView, 0);

        ViewGroup decor = (ViewGroup) getWindow().getDecorView();
        ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
        decorChild.setBackgroundColor(getResources().getColor(android.R.color.white));
        decor.removeView(decorChild);
        decor.addView(slidingPaneLayout);
        slidingPaneLayout.addView(decorChild, 1);
    }
}
 
開發者ID:paradoxie,項目名稱:SwipBackDemo,代碼行數:32,代碼來源:BaseActivity.java

示例4: onCreate

import android.support.v4.widget.SlidingPaneLayout; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    //通過反射來改變SlidingPanelayout的值
    try {
        slidingPaneLayout = new SlidingPaneLayout(this);
        Field f_overHang = SlidingPaneLayout.class.getDeclaredField("mOverhangSize");
        f_overHang.setAccessible(true);
        f_overHang.set(slidingPaneLayout, 0);
        slidingPaneLayout.setPanelSlideListener(this);
        slidingPaneLayout.setSliderFadeColor(getResources().getColor(android.R.color.transparent));
    } catch (Exception e) {
        e.printStackTrace();
    }
    super.onCreate(savedInstanceState);
    mFileTemp = new File(getCacheDir(), WINDOWBITMAP);
    defaultTranslationX = dip2px(defaultTranslationX);
    shadowWidth = dip2px(shadowWidth);
    //behindframeLayout
    FrameLayout behindframeLayout = new FrameLayout(this);
    behindImageView = new ImageView(this);
    behindImageView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
    behindframeLayout.addView(behindImageView, 0);

    //containerLayout
    LinearLayout containerLayout = new LinearLayout(this);
    containerLayout.setOrientation(LinearLayout.HORIZONTAL);
    containerLayout.setBackgroundColor(getResources().getColor(android.R.color.transparent));
    containerLayout.setLayoutParams(new ViewGroup.LayoutParams(getWindowManager().getDefaultDisplay().getWidth() + shadowWidth, ViewGroup.LayoutParams.MATCH_PARENT));
    //you view container
    frameLayout = new FrameLayout(this);
    frameLayout.setBackgroundColor(getResources().getColor(android.R.color.white));
    frameLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));

    //add shadow
    shadowImageView = new ImageView(this);
    shadowImageView.setBackgroundResource(R.drawable.parallax_swipe_back_shadow);
    shadowImageView.setLayoutParams(new LinearLayout.LayoutParams(shadowWidth, LinearLayout.LayoutParams.MATCH_PARENT));
    containerLayout.addView(shadowImageView);
    containerLayout.addView(frameLayout);
    containerLayout.setTranslationX(-shadowWidth);
    //添加兩個view
    slidingPaneLayout.addView(behindframeLayout, 0);
    slidingPaneLayout.addView(containerLayout, 1);
}
 
開發者ID:cymcsg,項目名稱:UltimateAndroid,代碼行數:45,代碼來源:ParallaxSwipeBackActivity.java


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