小编Fai*_*yaz的帖子

滚动选项卡中的片段时隐藏/显示工具栏

我添加了新的Toolbar,TablayoutViewpager在我的Android应用程序中.我为我的3个标签提供了碎片,它的工作正常.但问题是,当我向上滚动我的工具栏时,不会隐藏.我希望当我滚动我的片段时它应该隐藏.还有一件事,我在片段中使用Webview.我的代码如下.

MainActivity.Java

public class MainActivity extends AppCompatActivity {
    TabLayout tabLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

        setupToolbar();
        setupTablayout();
    }

private void setupToolbar() {
    // TODO Auto-generated method stub
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbarsdfs);
    if (toolbar != null) {
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);}
}

private void setupTablayout() {
    // TODO Auto-generated method stub
    tabLayout = (TabLayout) findViewById(R.id.tabLayout);
    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
    tabLayout.addTab(tabLayout.newTab().setText("Tab 1"));
    tabLayout.addTab(tabLayout.newTab().setText("Tab 2"));
    final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    final PagerAdapter adapter = new PagerAdapter
            (getSupportFragmentManager(), …
Run Code Online (Sandbox Code Playgroud)

android toolbar webview android-fragments android-tablayout

22
推荐指数
2
解决办法
3万
查看次数

在NestedScrollView Android 2.3或更低版本中滚动WebView

我添加了Toolbar,TablayoutViewpager在我的Android应用程序中.有三个TabsTabLayout,每个显示WebView.我把它WebView放在一个NestedScrollView隐藏/显示Toolbar用户向下/向上滚动的位置WebView.Toolbar隐藏在Android 3.0或更高版本中.但不幸的是,在Android 2.3或更低版本WebView中,首先不会滚动.我必须刷到另一个Tab,当我Tab再次回到First 时WebView开始滚动.

我想要的是?

我希望它WebView应该滚动Android 2.3或更少没有任何问题.

我的WebView

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:isScrollContainer="false"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:paddingTop="1dp">

     <WebView
         android:id="@+id/webviewtool"
         android:layout_width="match_parent"
         android:layout_height="fill_parent"
         android:numColumns="1"
         android:scrollbars="none"
         android:focusableInTouchMode="false"
         android:focusable="false"
         android:background="#FFFFFF" />

        </LinearLayout>
</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)

android toolbar webview android-viewpager nestedscrollview

10
推荐指数
1
解决办法
1135
查看次数

在加载WebView之前滑动以刷新隐藏

我为我的WebView实现了刷卡刷新,并且工作正常.但是有一个问题我无法解决.问题是我在6秒后刷卡刷新.在WebView的加载完成之前,它不会保留在那里.我想要的是刷新刷新应保持可见,直到页面完全加载.

我的实施

swipeView = (SwipeRefreshLayout) view.findViewById(R.id.swipe);
myWebView = (WebView) view.findViewById(R.id.webview);
myWebView.loadUrl("http://m.facebook.com");
swipeView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener()    
        {
        @Override
         public void onRefresh() 
         {
                     swipeView.setRefreshing(true);
                   ( new Handler()).postDelayed(new Runnable() 
                           {
                             @Override
                             public void run() 
                               {
                                swipeView.setRefreshing(false);
                                myWebView.loadUrl("http://m.facebook.com");
                               }
                         }, 6000);
                   }});
Run Code Online (Sandbox Code Playgroud)

android webview swipe-gesture

1
推荐指数
1
解决办法
1677
查看次数