android-support-library

Adding Support Libraries to Android project

眉间皱痕 提交于 2019-12-18 12:47:23
问题 Why am I having such a hard time getting into the swing of Android development? I've been developing in various languages over the years and, for some reason, just can't seem to get beyond that "jeez-i-still-feel-a-total-noob" stage with Android. So I'm trying to add an Action Bar to my Android 2.3.3 project. No problem, right? The Android developers website has a nice and clear article explaining exactly how to do it. Of course it involves adding the appcompat v7 support library. No problem,

Cardview corner background not transparent

白昼怎懂夜的黑 提交于 2019-12-18 12:26:42
问题 I have a custom implementation of a CardView support widget but I can't seem to get the background for the corners transparent when I include it in my layout-file. However, if I simply place the CardView support widget in my layout-file it suddenly works. How can I get the corners transparent for my custom component? This is the layout file for my custom implementation of the CardView: view_card.xml <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.CardView xmlns:android="http

Android support library increases APK size a lot

北城以北 提交于 2019-12-18 12:13:01
问题 I'm using AppCompat support library in my Android project. AppCompat has plenty of drawables and resources which I don't use in my app. That unnecessary files increases my 900K app to above 2M , which I don't like. Is there any way to exclude those files when creating the APK file? Or I should obfuscate the library in my code instead of making a dependency? I'm using Gradle in Android Studio. Thanks EDIT 1 I am using proguard already. but proguard can't know I don't want to have drawable

DrawableCompat setTint not working on API 19

给你一囗甜甜゛ 提交于 2019-12-18 11:48:52
问题 I am using the DrawableCompat for tinting drawable as below, tinting doesn't seem to be working on API 19. I am using the support lib version 23.3.0 Drawable drawable = textView.getCompoundDrawables()[drawablePosition]; if (drawable != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { drawable.setTint(color); } else { DrawableCompat.setTint(DrawableCompat.wrap(drawable), color); } } 回答1: I had the same problem. I combined the posts in https://stackoverflow.com/a/30928051

Android toolbar back arrow with icon like WhatsApp

女生的网名这么多〃 提交于 2019-12-18 11:34:54
问题 How to display icon with back arrow in android toolbar like WhatsApp ? I use below code to set back arrow & icon in toolbar. toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); toolbar.setLogo(icon); but i got result as below image. I want icon immediate next after back arrow. I don't want any gap between back

Android toolbar back arrow with icon like WhatsApp

*爱你&永不变心* 提交于 2019-12-18 11:34:07
问题 How to display icon with back arrow in android toolbar like WhatsApp ? I use below code to set back arrow & icon in toolbar. toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); toolbar.setLogo(icon); but i got result as below image. I want icon immediate next after back arrow. I don't want any gap between back

DialogFragment : NullPointerException (support library)

我的梦境 提交于 2019-12-18 11:24:52
问题 I'm using the excellent ACRA library to receive error reports from my apps. I'm receiving a lot of reports from customers concerning an NPE in DialogFragment, but Im unable to reproduce it : java.lang.NullPointerException at android.support.v4.app.DialogFragment.onActivityCreated(SourceFile:366) at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:892) at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1083) at android.support.v4.app.FragmentManagerImpl

“Field can be converted to a local variable” message appearing when setting Android ActionBar colour

时光怂恿深爱的人放手 提交于 2019-12-18 11:05:05
问题 After setting the colour of the Action Bar, actionBarColor in private String actionBarColor = "#B36305"; gets highlighted yellow and a warning is returned for some reason. What can be done to get rid of this warning? Field can be converted to a local variable public class MainActivity extends AppCompatActivity { private String actionBarColor = "#B36305"; private int getFactorColor(int color, float factor) { float[] hsv = new float[3]; Color.colorToHSV(color, hsv); hsv[2] *= factor; color =

Call requires API level 23 (current min is 14): android.app.Activity#requestPermissions,checkSelfPermission [duplicate]

孤街浪徒 提交于 2019-12-18 10:52:11
问题 This question already has answers here : The method checkSelfPermission(Context, String) is undefined for the type ContextCompat (3 answers) Closed 3 years ago . I am trying add run time permissions android(6.0.1) API 23,If I use SDK version( min and target version both 23 ) it woks fine, like below, <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="23" /> If I change android:minSdkVersion(less then 23) For example: I am getting error below: Call requires API level 23 (current

Fragment re-created on bottom navigation view item selected

跟風遠走 提交于 2019-12-18 10:33:14
问题 Following is my code for bottom navigation view item selected bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { Fragment fragment = null; switch (item.getItemId()) { case R.id.action_one: // Switch to page one fragment = FragmentA.newInstance(); break; case R.id.action_two: // Switch to page two fragment = FragmentB.newInstance(); break; case R.id