本文整理汇总了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);
}
示例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);
}
}
示例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);
}
}
示例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);
}