android-support-library

Android StaggeredGridLayoutManager offset bug

我的梦境 提交于 2019-12-04 12:18:33
问题 When you clear your adapter and call notifyDataSetChanged() - StaggedGridLayoutManager manager still has mCachedStart/End in Span[] instances. So when you add new items to adapter - layout manager draws items with offset , and this is a huge problem . EtsyStaggeredGridView has method resetToTop() which clears all cached stuff and draws everything from scratch. There are some workarounds: Call layoutManager.onDetachedFromWindow(recyclerView, null) after clearing an adapter Set new layout

Android NavigationView : not show full item and not truncate

对着背影说爱祢 提交于 2019-12-04 11:38:30
Problem : NavigationView not show full text of menu item, also not truncate text . This item I see correctly - two words " Small title ": <item android:id="@+id/example1" android:icon="@drawable/filter_2" android:title="Small title" android:checked="false" app:actionLayout="@layout/menu_counter" /> /> And with next item - I see only first two words " Small title " without any truncate of next word " andveryverylongword ": <item android:id="@+id/example2" android:icon="@drawable/filter_2" android:title="Small title andveryverylongword" android:checked="false" app:actionLayout="@layout/menu

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

Add an icon image beside the title on the collapsing layout

坚强是说给别人听的谎言 提交于 2019-12-04 10:47:57
I want to the add the image to the collapsing layout. I can add the text (title) but how do I add the image? please see the following code: <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/user_profile_coordinatorlayout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="500dp" android

Method call mActionBar=getActionBar() gives error [closed]

我们两清 提交于 2019-12-04 10:44:19
Closed. This question is off-topic. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I am using support library android.support.v7.app.actionbar because i want action bar in api level 8 and above But following sentence gives me error like change mActionBar to ActionBar mActionBar=getActionBar(); My FragmentActivity in which I wnat to use ActionBar Tab is as follows import com.example.bottomtabadapter.TabPageAdapter; import android.os.Bundle; import android.support.v7.app.ActionBar;

Blurry Image on API 21+ : AppCompat v23.2.0 using VectorDrawables with srcCompat

与世无争的帅哥 提交于 2019-12-04 10:25:55
I have an image display issue on API 21+, but everything works fine on lower devices and API 22+. I'm using Gradle Plugin 1.5, so my build.gradle look like this: // Gradle Plugin 1.5 android { defaultConfig { generatedDensities = [] } // This is handled for you by the 2.0+ Gradle Plugin aaptOptions { additionalParameters "--no-version-vectors" } } Image View in XML: <ImageView android:id="@+id/landing_img_slide" android:layout_width="225dp" android:layout_height="225dp" android:layout_centerHorizontal="true" android:scaleType="centerCrop" /> Java Code : ImageView iconView = (ImageView)

Android Studio 2.3 Beta 1 + Support 25.1.0 = Preview broken

心不动则不痛 提交于 2019-12-04 10:19:51
问题 Android Studio 2.3 Canary 3. Support libraries 25.1.0. Layout previews are totally broken. Anything that contains a support-related View seems to break during preview. In all cases, this is the beginning of the stack: Exception Details java.lang.NoSuchFieldError: ViewBackgroundHelper at android.support.v7.widget.AppCompatBackgroundHelper.loadFromAttributes(AppCompatBackgroundHelper.java:46) at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:63) at android.support

How to add Snackbars in a BroadcastReceiver?

て烟熏妆下的殇ゞ 提交于 2019-12-04 10:05:05
Snackbars provide lightweight feedback about an operation by showing a brief message at the bottom of the screen. Snackbars can contain an action. Android also provides a toast, primarily used for system messaging. Toasts are similar to snackbars but do not contain actions and cannot be swiped off screen. My question import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.widget.Toast; public class TestReceiver extends BroadcastReceiver { @Override public void onReceive(final Context context, final Intent intent) { Toast.makeText

What is the use case for ContextCompat.checkSelfPermission?

戏子无情 提交于 2019-12-04 09:43:02
Currently I have the following method to check for runtime permission in AppCompatActivity for Marshmallow : if(Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { boolean hasPermission = checkSelfPermission(Manifest.permission.XX) == PackageManager.PERMISSION_GRANTED; if(!hasPermission) { if(shouldShowRequestPermissionRationale(Manifest.permission.XX)) { // explain reason for permission, try again } else { // user deny with "don't show again" } } } So far I find it works reasonably well for Marshmallow. However, should I be worrying about permission in pre-M versions that I should use

CollapsingToolbarLayout ImageView is not scrollable

偶尔善良 提交于 2019-12-04 09:33:58
问题 Using cheesesquare - android support library example is it possible to make the Header ImageView scroll-able? <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="@dimen/detail_backdrop_height" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" android:fitsSystemWindows="true"> <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/collapsing_toolbar" android:layout_width="match_parent"