androiddesignsupport

Snackbar action text color not changing

青春壹個敷衍的年華 提交于 2019-12-05 08:28:10
问题 I want to change the action text color for my snackbar, but it is not working for some reason. I use the following code to display a snackbar: Snackbar.make(findViewById(R.id.root), "text", Snackbar.LENGTH_LONG).setActionTextColor(R.color.yellow).setAction("OK", new View.OnClickListener() { @Override public void onClick(View view) { } }).show(); 回答1: The argument of setActionTextColor is the int that represents the color, not the resource ID. Instead of this: .setActionTextColor(R.color

Single tab in TabLayout is not covering the entire width

隐身守侯 提交于 2019-12-05 05:20:35
I have created a view pager with TabLayout. Now the issue is if I have 2 or more tabs then everything is fine. But if I am having only one tab then it is not covering the entire screen width. PFA the xml layout <android.support.design.widget.TabLayout android:id="@+id/sliding_tabs" android:layout_width="match_parent" android:layout_height="wrap_content" app:tabGravity="fill" app:tabMode="fixed" style="@style/TabLayout" android:fillViewport="true" android:layout_below="@id/ssrToolbar"/> <android.support.v4.view.ViewPager android:id="@+id/viewpager" android:layout_width="match_parent" android

How to use Android AppBarLayout, Toolbar and TabLayout with fragments

烂漫一生 提交于 2019-12-05 01:12:51
问题 I have activity with NavigationDrawer and AppBarLayout with Toolbar. Unfortunately when I am using TabLayout in child fragment I see shadow between toolbar and TabLayout. Is it possible display shadow below TabLayout only? I do not want to move TabLayout to my activity because I'm using it only in one fragment. I can see few solutions for this problem: disable elevation on Toolbar & TabLaout ( don't like it) remove toolbar from activity and move it into fragment Do you have any ideas how to

SearchView is invisible with collapseActionView parameter since 24.1 design library

别等时光非礼了梦想. 提交于 2019-12-04 23:39:42
问题 I encountered a problem since I updated the Android Design Library from 23.4.0 to 24.1.1 My SearchView was defined like this : <item android:id="@+id/action_search" android:icon="@drawable/ic_search" android:title="@string/title_action_search" app:actionViewClass="android.support.v7.widget.SearchView" app:showAsAction="collapseActionView|ifRoom" /> But my SearchView input became invisible (I can write in it, but the text, or hint does not appear). I described it in the following picture with

findViewById(R.id.icon) returns null

℡╲_俬逩灬. 提交于 2019-12-04 21:42:59
R.id.icon is already defined in Android API level 1. However, I am getting an NPE in a Android Design Support Library internal code while accessing an imageview inflated using R.id.icon . NOTE: I am not targetting Oreo as my targetSdk is currently 25 . Here is the stacktrace: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewGroup$LayoutParams android.widget.ImageView.getLayoutParams()' on a null object reference at android.support.design.internal.BottomNavigationItemView.setChecked(BottomNavigationItemView.java:172) at android.support.design

Switch in Navigation drawer item with Design Support Library on Android

。_饼干妹妹 提交于 2019-12-04 11:22:24
问题 I need to put Switch inside item in navigation drawer. I'm using new design support library, but I cannot find if it is posibble at all. When using android:checkable item is just full selected and that is not what I wish. This is screenshot of what I really want. Is that possible to achieve that? 回答1: Your menu item for the navigation drawer: <item android:id="@+id/nav_item1" android:icon="@drawable/ic_item1" android:title="item1" app:actionLayout="@layout/layout_switch" /> and the layout for

“Hidden” Toolbar visible under status bar

孤者浪人 提交于 2019-12-04 09:54:25
Using the CoordinatorLayout to hide my toolbar when scrolling down. The toolbar thinks it's hidden - But it's not. Does anyone understand why this is happening? Note: I have the status bar set to translucent to have proper material drawers. Making the status bar a solid color is not the solution I'm looking for - Unless of course that is how this was intended to be used. I try to set statusbar color as the primarydark, then statusbar can not be transparent when drawer is opened otherwise toolbar comes out again. After two days work, I found that if I remove the android:fitsSystemWindows="true"

What is the difference between AppBarLayout vs Toolbar?

此生再无相见时 提交于 2019-12-04 07:29:05
问题 I want to include Toolbar in my app, but the design support library just came out with AppBarLayout , so I just need clarification on what the difference is and when I would use one over the other. 回答1: The AppBarLayout is used to achieve various scrolling behaviors such as collapse, flex space, and quick return. http://www.google.com/design/spec/patterns/scrolling-techniques.html http://android-developers.blogspot.com/2015/05/android-design-support-library.html 回答2: If you want just to

inflate menu in CollapsingToolbarLayout issue

元气小坏坏 提交于 2019-12-04 05:42:09
I am using the design support library`s CollapsingToolbarLayout.My issue is i am not able to inflate the menu action icon in toolbar. I am using the below code to create CollapsingToolbarLayout. <android.support.design.widget.AppBarLayout android:id="@+id/app_bar_layout" android:layout_width="match_parent" android:layout_height="240dp"> <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/collapsing_toolbar" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" app:contentScrim="?attr/colorPrimary" app

How to dim background when using the BottomSheet from the support library?

我的梦境 提交于 2019-12-04 03:15:20
How can the background be dimmed just like it is shown here ? I've set it up normally using the CoordinatorLayout and the BottomSheetBehavior . This will simply show a bottom sheet. public class MyBottomSheet extends BottomSheetDialogFragment { private static final String TAG = "MyBottomSheet"; @NonNull @Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final BottomSheetDialog dialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState); final View view = View.inflate(getContext(), R.layout.my_custom_view, null); dialog.setContentView(view); behavior =