我正在使用appcompat/support-v7中引入的新工具栏小部件.我想隐藏/显示工具栏,具体取决于用户是否在页面上下滚动,就像在新的Google Playstore应用程序或NewsStand应用程序中一样.工具栏小部件中是否有内置的东西,或者我应该将它与FrameLayout和ObservableScrollView结合使用?
如何WebView在Android中实现Scroll Listener
我试过这个,但它没有调用我Log.i滚动webview.
package com.example.webview.full.width;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.webkit.WebView;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
public class scorllableWebview extends WebView implements OnScrollListener {
Context ctx;
AttributeSet atrs;
public scorllableWebview(Context context) {
super(context);
ctx = context;
}
public scorllableWebview(Context context, AttributeSet atters){
super(context, atters);
ctx = context;
atrs = atters;
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
Log.i("onScroll", "Called");
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
Log.i("onScrollStateChanged", …Run Code Online (Sandbox Code Playgroud) Android 5.0框架是否具有Material-styled选项卡?我知道在开发预览中,它们仍然是Holo风格的.我想知道5.0是否已使用材质样式选项卡进行更新; 我目前使用PagerSlidingTabStrip作为我的选项卡,但尚未使用Material设计进行更新.
更具体地说,支持库是否包含材料选项卡的实现?在4.x上运行的Play商店有这些标签,但我不确定这是否是谷歌的自定义实现.
我需要创建一个带有a ListView和a的GUI,ActionBar当向下滚动时它会隐藏,当向上滚动时它必须重新出现.
以下指南对我没有帮助:
我需要这样的东西:

android listview android-appcompat android-actionbar android-design-library
好的,所以隐藏动作栏是可行的.但是,我们如何在活动中隐藏(新引入的)工具栏?
我正在创建一个主题为theme.apcompat.light.noactionbar的活动的应用程序(隐藏操作栏),我在其下方放置了一个带有slidingtablayout的工具栏.下面是我的列表视图.
我想要的是在滚动列表视图时隐藏工具栏.但滑动布局应保持在那里.如果我在列表视图的中间向下滚动,则工具栏应该再次可见.
我正在使用ViewPager在不同的片段之间滚动.使用两种不同的菜单资源有两种类型的片段.我正在使菜单无效,以便在必要时在这些资源之间切换.这一切都很好,但菜单是"重绘"没有动画.
为了防止不得不混淆单个MenuItems,我希望我可以在加载新菜单时暂时隐藏ActionBar,并在完成后显示它.这也正如预期的那样工作,但是当ActionBar切换时,活动会调整大小.
有没有办法防止这种情况发生,或者隐藏菜单资源之间的丑陋过渡?
这是我的设置,我正在运行DrawerLayout,其中包含一个包含AppBarLayout和nestedscrollview的CoordinatorLayout.我试图让nestedscrollview正常滚动,工具栏在向下滚动时隐藏,并在向上滚动时重新编辑.附在我的XML代码中.将不胜感激任何帮助..已阅读所有相关问题并实施他们的答案,但没有任何成功.
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout_admin"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/admincoordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="@+id/app_bar"
layout="@layout/app_bar"
app:layout_scrollFlags="scroll|enterAlways" />
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/adminrelScroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/drawer_header"
app:menu="@menu/menu_drawer" />
Run Code Online (Sandbox Code Playgroud)
tabs toolbars drawerlayout material-design android-coordinatorlayout
我正在尝试工具栏和TabLayout,当你滚动循环视图时,它应该像whatsapp应用程序一样隐藏工具栏.我指的是谷歌博客和Michal Z的博客.我在主要活动中查看了寻呼机,我正在使用recycleview显示其中的数据列表.
坦率地说,我被新的谷歌设计库所震撼,因为只需一行XML代码就可以改变完整的UI和UI行为.理想情况下,我们需要app:layout_scrollFlags="scroll|enterAlways"在工具栏中添加一行,它才能正常工作.但对我来说它不起作用.我已在API 19和21设备上测试过它.
通过在堆栈溢出和各种博客博客上的问题 问题,我找到2种方法来实现这个功能1.通过提供滚动监听器到recycleview和2.通过将可滚动内容放在里面.但它没有按预期工作. NestedScrollView
我认为它应该没有编写任何代码.
主Activity.xml
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:background="@color/colorPrimary"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/Base.ThemeOverlay.AppCompat.Dark"/>
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
android:background="@color/colorPrimaryDark"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
ViewPagerFragment.xml
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_refresh_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/windowBackground">
<android.support.v7.widget.RecyclerView
android:id="@+id/order_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft= "true"
android:layout_alignParentStart="true"
android:layout_above="@+id/txtStatus" />
</android.support.v4.widget.SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud) android android-toolbar android-design-library android-coordinatorlayout android-appbarlayout
我正在尝试在Android中编写代码,以在向下滚动事件期间隐藏Actionbar.我有一个10x50的网格.因此,当我向下滚动时,操作栏应该隐藏.我正确地在Log Cat中获得滚动状态结果,所以每当我申请getActionBar()时,我都会收到NullPointerException错误.
我的代码:
package com.example.complexdatepicker;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class MainActivity extends TabActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TabHost tabHost = getTabHost();
TabSpec tab1 = tabHost.newTabSpec("Home");
tab1.setIndicator("Home");
Intent photosIntent = new Intent(this, Home.class);
tab1.setContent(photosIntent);
tabHost.addTab(tab1);
}
}
Run Code Online (Sandbox Code Playgroud)
Home.java
package com.example.complexdatepicker;
import java.util.ArrayList;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.widget.GridView;
public class Home extends ActionBarActivity
{
ArrayList<String> abc;
TestGrid tg;
GridView gv;
int mLastFirstVisibleItem;
int mLastVisibleItemCount;
@Override
protected void onCreate(Bundle savedInstanceState) …Run Code Online (Sandbox Code Playgroud) android nullpointerexception android-tabactivity android-actionbar
android ×7
android-tabs ×1
drawerlayout ×1
listview ×1
scrollview ×1
tabs ×1
toolbars ×1
webview ×1