material-design

Set Toolbar Icon Colour Programmatically

蹲街弑〆低调 提交于 2019-12-30 10:44:39
问题 How can I set the colour of icons (home and overflow menu icon) in a Toolbar / AppBarLayout programmatically ? I want to change the toolbar's colour scheme for a single fragment in an activity. Setting the AppBarLayout 's background to a light colour (e.g. light gray with appBarLayout.setBackgroundResource(..); ) results in white icons and a white title which are barely visible. Its layout is as follows: <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width

How to apply setItemChecked(position,true) with RecyclerView in Android?

試著忘記壹切 提交于 2019-12-30 06:18:11
问题 I am developing a Material Design Navigation Drawer. I've created a new class RecyclerItemClickListener implements RecyclerView.OnItemTouchListener in it to handle the user's click on the list items. I use the class this way within the MainActivity class' onCreate method: mRecyclerView.addOnItemTouchListener( new RecyclerItemClickListener(this, mRecyclerView, new RecyclerItemClickListener.OnItemClickListener() { @Override public void onItemClick(View view, int position) {// do whatever if

Android FAB behaviour with listview for custom layout

混江龙づ霸主 提交于 2019-12-30 05:28:07
问题 I would like to achieve behaviour similar to this example but without toolbar move and for custom view not for a FAB. So, firstly i would like to see layout similar to https://www.google.com/design/spec/components/bottom-sheets.html (it can be simple LinearLayout placed on bottom of the screen with some child views) which hides when i start scroll down listview and appears when i scroll up a little. Have digged deep in web but found nothing what really works. Thanks in advance. 回答1: First you

Swift 3- How to get button in UICollectionViewCell work

若如初见. 提交于 2019-12-30 05:08:09
问题 I am trying to implement an Edit button inside a cell. Please refer to image: What I done so far: MainController: class MainController: UICollectionViewController, UICollectionViewDelegateFlowLayout { let imgCellId = "imgCellId" override func viewDidLoad() { collectionView?.backgroundColor = .white collectionView?.register(ImgItemCell.self, forCellWithReuseIdentifier: imgCellId) } override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) ->

How to add checkbox to material navigation drawer?

时光毁灭记忆、已成空白 提交于 2019-12-30 02:11:06
问题 I use Menu items Icon Menu but I want to add checkbox to all menu item. This is my drawer_menu.xml <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <group android:checkableBehavior="all"> <item android:checked="false" android:id="@+id/item_navigation_drawer_inbox" android:icon="@drawable/ic_inbox_black_24dp" android:checkable="true" android:title="Inbox" /> <item android:id="@+id/item_navigation_drawer_starred" android:icon="@drawable/ic

NullPointerException with AppCompat BottomSheets

吃可爱长大的小学妹 提交于 2019-12-29 08:27:54
问题 LinearLayout bottomSheetViewgroup = (LinearLayout) findViewById(R.id.bottomSheet); bottomSheetBehavior = BottomSheetBehavior.from(bottomSheetViewgroup); bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); //this line I have this code within my activity's onCreate() method and I'm getting the below NPE exception when the last line is executed: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.ref.WeakReference.get()' on a null

Extending Preference classes in Android Lollipop = losing animation

人盡茶涼 提交于 2019-12-29 07:41:50
问题 Just for extending CheckBoxPreference or SwitchPreference on Android Lollipop, the widget (the checkbox or the switch) won't have animation anymore. I'd like to extend SwitchPreference to force api < 21 to use SwitchCompat instead of the default one they are using (which is obviously wrong). I am using the new AppCompatPreferenceActivity with appcompat-v7:22.1.1 but that doesn't seem to affect the switches. The thing is that with just extending those classes, without adding any custom layout

How to disable scrolling of NestedScrollView&CollapsingToolbarLayout, for example when there is no more content below?

情到浓时终转凉″ 提交于 2019-12-29 02:33:12
问题 Background I try to add the same functionality as shown on many apps, where the upper area of the screen shrinks&expands according to the scrolled content. For this, I use Google's design library, as shown on the CheeseSquare sample. The problem Thing is, no matter how much content there is in the NestedScrollView , it lets me scroll way below the last view of the content, just to let me see the final state of the actionbar, having the minimal size of itself. In short, this is what I see when

What is the difference between Action Bar and newly introduced Toolbar?

三世轮回 提交于 2019-12-29 02:18:27
问题 After Google introduced Material Design, I have heard about a new widget class called Toolbar. What is the Toolbar, and what is the exact difference between ActionBar and ToolBar? 回答1: I found a good explanation from Android Developers Blog post. In this release, Android introduces a new Toolbar widget. This is a generalization of the Action Bar pattern that gives you much more control and flexibility. Toolbar is a view in your hierarchy just like any other, making it easier to interleave

Floating action button issue when going to another fragment

夙愿已清 提交于 2019-12-29 00:40:10
问题 I built a project based on Scrolling Activity (pre-built activity suggested by android studio) and faced a strange issue. Consider the following scenario: I clicked on fab button to go to another fragment but when the fragment changed, the fab button is not disappeared ! Can anybody know how to fix this problem? Here is my XML of Scrolling Activity that I added to my frameLayout : <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http:/