Shape drawable as background, a line at the bottom

This is how I got a line at the bottom for mine. Draw a stroke but then shift the item up and to the sides to get the top and sides to not show the stroke: <?xml version=”1.0″ encoding=”utf-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:top=”-8dp” android:left=”-8dp” android:right=”-8dp”> <shape> <solid android:color=”#2b7996″/> <stroke android:color=”#33b5e5″ android:width=”6dp”/> </shape> </item> </layer-list>

Contact Bubble EditText

Thanks @chrish for all the help. So here is how i did it: final SpannableStringBuilder sb = new SpannableStringBuilder(); TextView tv = createContactTextView(contactName); BitmapDrawable bd = (BitmapDrawable) convertViewToDrawable(tv); bd.setBounds(0, 0, bd.getIntrinsicWidth(),bd.getIntrinsicHeight()); sb.append(contactName + “,”); sb.setSpan(new ImageSpan(bd), sb.length()-(contactName.length()+1), sb.length()-1,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); to_input.setText(sb); public TextView createContactTextView(String text){ //creating textview dynamically TextView tv = new TextView(this); tv.setText(text); tv.setTextSize(20); tv.setBackgroundResource(R.drawable.oval); tv.setCompoundDrawablesWithIntrinsicBounds(0, … Read more

How to programmatically set drawableRight on Android Edittext?

You can use the function below: editText.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.drawableRight, 0); or (if you want to pass the drawable itself instead of its ID) editText.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(context,R.drawable.drawableRight), null) The order of params corresponding to the drawable location is: left, top, right, bottom

Why isn’t my vector drawable scaling as expected?

There is new info about this issue here: https://code.google.com/p/android/issues/detail?id=202019 It looks like using android:scaleType=”fitXY” will make it scale correctly on Lollipop. From a Google engineer: Hi, Let me know if scaleType=”fitXY” can be a workaround for you , in order to get the image look sharp. The marshmallow Vs Lollipop is due to a special … Read more

Is it possible to rotate a drawable in the xml description?

I could rotate in XML: <?xml version=”1.0″ encoding=”utf-8″?> <rotate xmlns:android=”http://schemas.android.com/apk/res/android” android:fromDegrees=”90″ android:toDegrees=”90″ android:pivotX=”50%” android:pivotY=”50%” android:drawable=”@drawable/mainmenu_background”> </rotate> The fromDegrees is important. Basically this is a rotate animation defined in XML. With fromDegrees you define the initial rotated state. The toDegrees is the final rotated state of the drawable in the animation sequence but can be anything … Read more