gpt4 book ai didi

android - 如何通过向右拖动主页来停止滑动

转载 作者:行者123 更新时间:2023-11-30 03:20:00 28 4
gpt4 key购买 nike

我已经完成了 MenuSlider,但我只想在单击 actionBar 主页按钮时滑动如何操作我不知道如何解决此问题,因为我必须添加 4 个选项卡然后导航到它们似乎很困难

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
StrictMode.enableDefaults();


Drawable d=getResources().getDrawable(R.drawable.action_bar);

actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
//actionBar.setTitle("Action Bar");
actionBar.setLogo(R.drawable.transparent);
//actionBar.setSubtitle("http://www.android.com");
actionBar.addOnMenuVisibilityListener(this);
actionBar.setBackgroundDrawable(d);


actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayUseLogoEnabled(true);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
getActionBar().setHomeButtonEnabled(true);
getOverflowMenu();

setBehindContentView(R.layout.left_tab);
setSlidingActionBarEnabled(true);
slideMenu = getSlidingMenu();
slideMenu.setMode(SlidingMenu.LEFT);
slideMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
slideMenu.setShadowWidthRes(R.dimen.slidingmenu_offset);
//slideMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
slideMenu.setBehindOffset(80);
slideMenu.setFadeDegree(0.99f);

inflater = getLayoutInflater();
//item = inflater.inflate(R.layout.left_tab, null);}
}

最佳答案

尝试改变

slideMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

slideMenu.setTouchModeAbove(SlidingMenu.ABOVE); 

touchModeAbove - an enum that designates what part of the screen is touchable when the above view is showing. Margin means only the left margin. Fullscreen means the entire screen. Default is margin.


简单示例

public class SlidingExample extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(R.string.attach);
// set the content view
setContentView(R.layout.content);
// configure the SlidingMenu
SlidingMenu menu = new SlidingMenu(this);
menu.setMode(SlidingMenu.LEFT);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menu.setShadowWidthRes(R.dimen.shadow_width);
menu.setShadowDrawable(R.drawable.shadow);
menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
menu.setFadeDegree(0.35f);
menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
menu.setMenu(R.layout.menu);
}

}

XML 用法

如果您决定使用 SlidingMenu 作为 View ,您可以在 xml 布局中定义它,如下所示:

<com.jeremyfeinstein.slidingmenu.lib.SlidingMenu
xmlns:sliding="http://schemas.android.com/apk/res-auto"
android:id="@+id/slidingmenulayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
sliding:viewAbove="@layout/YOUR_ABOVE_VIEW"
sliding:viewBehind="@layout/YOUR_BEHIND_BEHIND"
sliding:touchModeAbove="margin|fullscreen"
sliding:behindOffset="@dimen/YOUR_OFFSET"
sliding:behindWidth="@dimen/YOUR_WIDTH"
sliding:behindScrollScale="@dimen/YOUR_SCALE"
sliding:shadowDrawable="@drawable/YOUR_SHADOW"
sliding:shadowWidth="@dimen/YOUR_SHADOW_WIDTH"
sliding:fadeEnabled="true|false"
sliding:fadeDegree="float"
sliding:selectorEnabled="true|false"
sliding:selectorDrawable="@drawable/YOUR_SELECTOR"/>

This class was deprecated in API level 17. This class is not supported anymore. It is recommended you base your own implementation on the source code for the Android Open Source Project if you must use it in your application.

输出:

enter image description here

关于android - 如何通过向右拖动主页来停止滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19333215/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com