相关疑难解决方法(0)

android棒棒糖工具栏:如何在滚动时隐藏/显示工具栏?

我正在使用appcompat/support-v7中引入的新工具栏小部件.我想隐藏/显示工具栏,具体取决于用户是否在页面上下滚动,就像在新的Google Playstore应用程序或NewsStand应用程序中一样.工具栏小部件中是否有内置的东西,或者我应该将它与FrameLayout和ObservableScrollView结合使用?

material-design android-5.0-lollipop android-toolbar

55
推荐指数
5
解决办法
10万
查看次数

当我在android中滚动内容时如何隐藏ToolBar

我正在尝试隐藏我的工具栏,当我滚动我的文本和图像与内容,这里我使用scrollView获取滚动内容时,当我滚动内容如何隐藏工具栏请任何人告诉我如何获得

这是我的XMl代码

content_main.XML

<android.support.v4.widget.NestedScrollView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
app:layout_behavior="@string/appbar_scrolling_view_behavior">


<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<LinearLayout
    android:paddingTop="?android:attr/actionBarSize"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:id="@+id/textone"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:textSize="23dp"
        android:textStyle="bold"
        android:text="hello world jheds sdjhs jds sjbs skjs ksjs kksjs ksj sdd dskd js sk "/>

    <ImageView
        android:id="@+id/imge"
        android:layout_width="match_parent"
        android:layout_height="250dp"
        android:src="@drawable/imag_bg"/>


    <TextView
        android:id="@+id/texttwo"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:text="Pretty good, the Toolbar is moving along with the list and getting back just as we expect it to. This is thanks to the restrictions that we put …
Run Code Online (Sandbox Code Playgroud)

android android-support-library android-toolbar android-support-design

24
推荐指数
1
解决办法
5万
查看次数

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

我添加了新的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万
查看次数

用户滚动时,如何在工具栏中为视图设置动画?

我想在我的应用程序中添加一些动画.请找到附带的照片以获得动画创意.

工具栏是购物车图标矩形,search_layout在其下方.

我用过CoordinatorLayout.我的搜索布局和工具栏托管在AppBarLayout/CollapsingToolbarLayout中.下面是我的NestedScrollView托管片段.

当用户使用滚动标志滚动时,我能够隐藏搜索布局.我正在尝试实现一个CoordinatorLayout.Behavior,它将开始向左移动购物车图标并开始搜索图标从0到1缩放; 一旦用户滚动并且搜索布局开始隐藏.当搜索布局完全隐藏时,我想在第二个屏幕中显示工具栏.当用户向下滚动并且通过向右移动推车并缩小搜索图标开始显示搜索布局时,它将返回到原始状态,如第一个屏幕所示.

最初我将工具栏上的搜索图标设为隐藏,购物车图标和搜索图标位于线性布局内.

请找到我的xml activity_home_page.xml

<?xml version="1.0" encoding="utf-8"?>
<com.example.ui.customviews.CustomDrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/ab_app_bar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.design.widget.CollapsingToolbarLayout
                android:layout_width="match_parent"
                android:layout_height="131dp"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">

                <LinearLayout
                    android:id="@+id/ll_search_layout"
                    android:layout_width="match_parent"
                    android:layout_height="75dp"
                    android:layout_gravity="bottom"
                    android:orientation="vertical"
                    android:visibility="visible"
                    app:layout_scrollFlags="scroll|snap">

                    <LinearLayout
                        android:id="@+id/ll_search_box"
                        android:layout_width="match_parent"
                        android:layout_height="51dp"
                        android:layout_marginBottom="@dimen/dimen_12_dp"
                        android:layout_marginLeft="@dimen/dimen_8_dp"
                        android:layout_marginRight="@dimen/dimen_8_dp"
                        android:layout_marginTop="@dimen/dimen_12_dp"
                        android:background="@drawable/round_corner_layout_white"
                        android:elevation="@dimen/dimen_5_dp"
                        android:focusableInTouchMode="true"
                        android:orientation="horizontal">

                        <EditText
                            android:id="@+id/et_search"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_gravity="center"
                            android:layout_marginLeft="@dimen/dimen_15_dp"
                            android:layout_weight="80"
                            android:background="@android:color/transparent"
                            android:hint="Search for Products"
                            android:padding="@dimen/dimen_5_dp"
                            android:textColor="@color/black"
                            android:textColorHint="@color/hint_text_color"
                            android:textSize="@dimen/dimen_text_16_sp" />

                        <ImageView
                            android:id="@+id/iv_search_icon"
                            android:layout_width="@dimen/dimen_22_dp"
                            android:layout_height="@dimen/dimen_24_dp"
                            android:layout_gravity="center"
                            android:layout_marginLeft="@dimen/dimen_17_dp"
                            android:layout_marginRight="@dimen/dimen_20_dp"
                            android:src="@drawable/ic_search_grey" />
                    </LinearLayout>

                </LinearLayout>

                <include
                    layout="@layout/layout_primary_toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/toolbar_primary_height"
                    android:layout_gravity="top" …
Run Code Online (Sandbox Code Playgroud)

animation android android-animation objectanimator

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