android-design-library

How to make a CardView have a clickable&checkable effect, and how to make it dark themed?

偶尔善良 提交于 2019-12-02 02:30:36
问题 Background Before CardView was introduced, I made some selectors on my app to mimic cards, and let the user also choose which theme to use for the app (some prefer a dark theme) : The problem I wanted to make it look&work more natively, so I tried using CardView. Sadly, I fail to understand how to set the CardView have a clickable&checkable effect (the native one of each platform, maybe with a different color), and also have the ability to set it a dark theme. The questions How do I make a

TextInputLayout setError method throws ClassCastException in 24.2.0

空扰寡人 提交于 2019-12-01 18:35:13
I updated support lib version to 24.2.0 and my registration screen is dead now. The problem is in the TextInputLayout, I have two methods: protected void setError(@Nullable CharSequence errorMsg, @NonNull EditText editText, boolean forceClean) { TextInputLayout viewParent = (TextInputLayout) editText.getParent(); if (forceClean) { viewParent.setErrorEnabled(false); viewParent.setError(null); } viewParent.setErrorEnabled(true); viewParent.setError(errorMsg); } protected void clearError(@NonNull EditText editText) { TextInputLayout viewParent = (TextInputLayout) editText.getParent(); viewParent

Android: Multiple snackbars in separate Fragments (ViewPager)

痞子三分冷 提交于 2019-12-01 15:33:10
问题 I have a viewpager, with a few fragments of course. Each of these fragments have CoordinatorLayout as parent. I'm showing a snackbar for something. The problem is, if Fragment A shows a snackbar it's fine, but if it's adjacent fragment B also shows a snackbar the snackbar in fragment A automatically hides. Since viewpager adjacent fragments are preloaded, it's a visible issue. Any workaround? Or am I doing it wrong? 回答1: There is a few problems with snackbar in multiple Fragments in ViewPager

How to add an ImageView with the title in collapsingtoolbarlayout in Android

瘦欲@ 提交于 2019-12-01 14:05:33
I am using CoordinatorLayout to get this effect Here is the layout code. <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/coordinatorRootLayout" android:background="@android:color/background_light" android:fitsSystemWindows="true" > <android.support.design.widget.AppBarLayout android:id="@+id/android_appbar_layout" android:layout_width="match_parent" android

How to add an ImageView with the title in collapsingtoolbarlayout in Android

纵然是瞬间 提交于 2019-12-01 12:17:45
问题 I am using CoordinatorLayout to get this effect Here is the layout code. <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/coordinatorRootLayout" android:background="@android:color/background_light" android:fitsSystemWindows="true" > <android.support.design

CoordinatorLayout status bar padding disappears during fragment transactions

折月煮酒 提交于 2019-12-01 06:11:22
With the 22.2.1 Design Support Library and API 22(have not tested on earlier versions yet), I'm running into issues with the status bar padding when switching between fragments. The initial fragment loads fine, but after a fragment transaction, the status bar padding disappears, pushing all the views up where they shouldn't be. The same thing happens to the original fragment after popping the back stack. Rotating the device fixes it, as does opening the soft keyboard(but only in portrait, not in landscape). main fragment on initial load or after rotation(desired) main fragment after back

Programmatically show Toolbar after hidden by scrolling (Android Design Library)

一个人想着一个人 提交于 2019-12-01 03:41:33
I have the following layout: a drawer, with the main content view having a AppBarLayout, RecyclerView and a TextView. When I scroll the recycler, the toolbar is correctly hidden. However, I have a use case: when all items from the recycler are removed, I sets its visibility to 'gone' and a TextView with an appropriate message it shown instead. If this is done while the toolbar is hidden, it is not possible for the user to see the toolbar again. Is it possible to programmatically cause the toolbar to be fully shown? I would do this whenever the TextView is shown instead of the RecyclerView.

TabLayout selected tab gravity

时间秒杀一切 提交于 2019-12-01 03:15:39
TabLayout is set up with ViewPager , has a lot of tabs, MODE_SCROLLABLE and keyline app:tabContentStart="72dp" . When user selects a tab, TabLayout tries to scroll the selected tab to the center. I would like the selected tab to be left aligned to keyline, not centered. Is it possible? Android Design Support Library v22.2.0. Unfortunately the method calculateScrollXForTab() of TabLayout is private and then not replaceable by subclasses. Either way you can copy the source TabLayout in your project, then possibly extending it with your class, and change the method calculateScrollXForTab() like

CoordinatorLayout layout_anchor does not work

主宰稳场 提交于 2019-12-01 02:44:49
I just tried out the new Support Design Library with CoordinatorLayout, but I'm having problems anchoring child views. My layout currently looks like this: <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/coordinator_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style

Translucent StatusBar with dynamic ActionBar color in Android

好久不见. 提交于 2019-12-01 01:31:11
问题 I'm trying to realize a translucent statusbar (so that my navigation-view is BEHIND the statusbar) but still like to change the color of my actionbar dynamically. Because of this, the statusbar color needs to change to a darker version of my actionbar color. If I set my statusbar to transparent, as many sources suggest, my primary_dark color is used as the background of my statusbar. However, as I will change the actionbar color during runtime, primary_dark must not necessarily be the dark