动作工具栏,神秘间隙android

时间:2016-07-27 01:45:29

标签: android android-layout

我不知道这是什么问题..但这很恶心,让我的应用看起来很糟糕..

这里是问题的截图

enter image description here

我不知道它来自哪里...... 我给你我的工具栏XML

Toolbar.XML

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?attr/actionBarSize"
    android:background="@color/colorPrimary"
    local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    android:elevation="4dp"
    style="@style/Widget.AppCompat.Light.ActionButton" />

我在我的mainActivity布局上展示..这是我的mainActivity布局

ContentMain.XML

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.study.MainActivity">


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

        <include
            android:id="@+id/toolbar"
            layout="@layout/toolbar" />

        <FrameLayout
            android:id="@+id/container_body"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="1" />

    </LinearLayout>


    <fragment
        android:id="@+id/fragment_navigation_drawer"
        android:name="com.example.study.fragment.FragmentDrawer"
        android:layout_width="@dimen/nav_drawer_width"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:layout="@layout/fragment_navigation_drawer"
        tools:layout="@layout/fragment_navigation_drawer"
        />

</android.support.v4.widget.DrawerLayout>

但是这个问题dissapear如果我去另一个片段然后回到主片段

enter image description here

我已经尝试重新安装应用程序..并重建项目..构建清洁项目..它不起作用

图像显示在frameLayout中实现的片段,在我的片段中有一个滑块显示图像。

FragmentHome.XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:custom="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:fitsSystemWindows="true"
    tools:context="com.example.study.fragment.HomeFragment">

            <com.example.study.slider_library.SliderLayout
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:id="@+id/slider"
                custom:pager_animation="Accordion"
                custom:auto_cycle="true"
                custom:indicator_visibility="visible"
                custom:pager_animation_span="1100"
                android:background="#202020"
                android:drawingCacheQuality="auto" />
</LinearLayout>

这是我FragmentHome

的一个java代码

HomeFragment.Java

public class HomeFragment extends android.support.v4.app.Fragment
        implements BaseSliderView.OnSliderClickListener, ViewPagerEx.OnPageChangeListener {


    private HashMap<String,String> url_maps;
    private SliderLayout mDemoSlider;

    public HomeFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View layout = inflater.inflate(R.layout.fragment_home, container, false);

        mDemoSlider = (SliderLayout) layout.findViewById(R.id.slider);


        HashMap<String,String> url_maps = new HashMap<>();

        url_maps.put("Hannibal", "http://static2.hypable.com/wp-content/uploads/2013/12/hannibal-season-2-release-date.jpg");
        url_maps.put("Big Bang Theory", "http://tvfiles.alphacoders.com/100/hdclearart-10.png");
        url_maps.put("House of Cards", "http://cdn3.nflximg.net/images/3093/2043093.jpg");
        url_maps.put("Game of Thrones", "http://images.boomsbeat.com/data/images/full/19640/game-of-thrones-season-4-jpg.jpg");


        for(String name : url_maps.keySet()){
            DefaultSliderView DefaultSliderView = new DefaultSliderView(getContext());
            // initialize a SliderLayout
            DefaultSliderView
                    .image(url_maps.get(name))
                    .setScaleType(BaseSliderView.ScaleType.Fit)
                    .setOnSliderClickListener(this);

            //add your extra information
            DefaultSliderView.bundle(new Bundle());
            DefaultSliderView.getBundle()
                    .putString("extra",name);

            mDemoSlider.addSlider(DefaultSliderView);
        }

        mDemoSlider.setPresetTransformer(SliderLayout.Transformer.Tablet);
        mDemoSlider.setPresetIndicator(SliderLayout.PresetIndicators.Center_Bottom);
        mDemoSlider.setDuration(400);
        mDemoSlider.addOnPageChangeListener(this);


        // Inflate the layout for this fragment
        return layout;

    }


    @Override
    public void onDetach() {
        super.onDetach();
    }

    @Override
    public void onStop() {
        // To prevent a memory leak on rotation, make sure to call stopAutoCycle() on the slider before activity or fragment is destroyed
        mDemoSlider.stopAutoCycle();
        super.onStop();
    }

    @Override
    public void onSliderClick(BaseSliderView slider) {
        Toast.makeText(getContext(),slider.getBundle().get("extra") + "",Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {}

    @Override
    public void onPageSelected(int position) {
        Log.d("Slider Demo", "Page Changed: " + position);
    }

    @Override
    public void onPageScrollStateChanged(int state) {}
}

0 个答案:

没有答案