当前位置: 首页>>代码示例>>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;未经允许,请勿转载。