Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to style top border? #3

Closed
zhangzhzh opened this issue Mar 17, 2016 · 7 comments
Closed

How to style top border? #3

zhangzhzh opened this issue Mar 17, 2016 · 7 comments
Labels

Comments

@zhangzhzh
Copy link

the top border is ugly, how to style it, such as color, size, and so on?

2016-03-17 08 56 45

@LiuDeng
Copy link

LiuDeng commented Mar 17, 2016

download the source code to read

@roughike roughike added the bug label Mar 17, 2016
@roughike
Copy link
Owner

@zhangzhzh
How did you get it to look like that? It would be helpful if you provide some code to duplicate your problem so I can fix it.

@AlexLionne
Copy link

its about the shadow, there is not methods in support libs to implement it as shadow(elevation) instead like this ? I mean like a toolbar elevation

@roughike
Copy link
Owner

Yes there is, but the direction of the shadow can't be changed, so the shadow won't show above the BottomBar.

@zhangzhzh
Copy link
Author

@roughike
I just set the LinearLayout's android:background to black in the activity_main.xml:

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:orientation="vertical">

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

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

menu.xml:

<item
    android:id="@+id/bottomBarHome"
    android:icon="@drawable/ic_home"
    android:title="@string/nav_item_home" />
......

MainActivity.java:

@OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

    mToolbar = (Toolbar) findViewById(R.id.toolbar);

    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

    mBottomBar = BottomBar.attach(this, savedInstanceState);
    mBottomBar.setItemsFromMenu(R.menu.menu_bottombar, new OnMenuTabSelectedListener() {
        @Override
        public void onMenuItemSelected(int resId) {
            switch (resId) {
                case R.id.bottomBarHome:
                    displayView(0);
                    break;
                ...
                default:
                    displayView(0);
                    break;
            }
        }
    });

    displayView(0);
}

private void displayView(int position) {
Fragment fragment = null;
switch (position) {
case 0:
fragment = new HomeFragment();
break;
......
default:
fragment = new HomeFragment();
break;
}

    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.replace(R.id.container_body, fragment);
    fragmentTransaction.commit();
}

@roughike
Copy link
Owner

@zhangzhzh
Alrighty then, I'll add an option for turning the shadow off in the next release (soon...!). Stay tuned!

@roughike
Copy link
Owner

Now you can hide the shadow in the library version 1.0.3 by calling bottomBar.hideShadow().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants