remove padding around action bar left icon on Android 4.0+

Digging into AOSP sources, it seems the code involved is in com.android.internal.widget.ActionBarView.java. In particular the relevant part is the onLayout() method of the inner class ActionBarView$HomeView, partially reported below (lines 1433-1478): @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { … final LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams(); final int iconHeight … Read more

Android Studio Project: bottom of UI is cut off

This is because you are using CoordinatorLayout with ListView. You can change your implementation to RecyclerView to achieve correct scroll. or If you are tagetting above 5.0, you can use the following piece of code if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { listView.setNestedScrollingEnabled(true); } I think CoordinatorLayout only works with the children of NestedScrollingChild.

How to make bottom navigation show menu items with icon and text except center item menu show only icon? [closed]

Try below code: XML file: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout 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:orientation=”vertical”> <android.support.v7.widget.Toolbar android:id=”@+id/toolbar” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_gravity=”top” android:background=”@color/gray” android:foregroundGravity=”top” android:gravity=”top”> </android.support.v7.widget.Toolbar> <FrameLayout android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_weight=”1″> <FrameLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@+id/fragment_container” android:layout_width=”match_parent” android:layout_height=”match_parent” /> </FrameLayout> <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”horizontal”> <android.support.design.widget.BottomNavigationView android:id=”@+id/bottomnav” android:layout_width=”0dp” android:layout_height=”56dp” android:layout_weight=”1″ android:background=”null” app:itemIconTint=”@color/green” app:itemTextColor=”@color/green” app:menu=”@menu/main”> </android.support.design.widget.BottomNavigationView> <ImageView android:layout_width=”0dp” android:layout_height=”56dp” android:layout_weight=”0.5″ android:src=”https://stackoverflow.com/questions/44342530/@drawable/camera” /> <android.support.design.widget.BottomNavigationView … Read more

Setting background color for Spinner Item on selection

create a xml: for ex:mybg.xml <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:state_pressed=”false” android:drawable=”@color/anyColor” /> <item android:drawable=”@android:color/transparent” /> </selector> and in your activity xml do <Spinner…………… android:drawSelectorOnTop=”true” android:background=”@drawable/mybg”/>

Spinner’s scrollbar style

After hours of work, I got the right solution (Thanks Khaled for guiding me to the right direction). You need a custom spinner: import java.lang.reflect.Field; import java.lang.reflect.Method; import org.holoeverywhere.widget.ListPopupWindow; import org.holoeverywhere.widget.ListView; import org.holoeverywhere.widget.Spinner; import android.content.Context; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.View; public class CustomSpinner extends Spinner { public CustomSpinner(Context context) { super(context); } public CustomSpinner(Context … Read more

How to add rectangles on top of existing rectangle in canvas

Try this: public class RectangleTextView extends View { private final Paint mBlackPaint = new Paint(); private final Paint mRedPaint = new Paint(); private final TextPaint mTextPaint; public RectangleTextView(Context context, AttributeSet attrs) { super(context, attrs); int valueInDp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()); int valueInSp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 20, getResources().getDisplayMetrics()); mRedPaint.setColor(Color.parseColor(“#CC3333”)); mBlackPaint.setAntiAlias(false); mBlackPaint.setColor(Color.BLACK); mBlackPaint.setStrokeWidth(valueInDp); mBlackPaint.setStyle(Paint.Style.STROKE); mTextPaint = … Read more

Why Bitmap to Base64 String showing black background on webview in android?

The JPEG format does not support alpha transparency, which is why the transparent background becomes black when you convert your original image to JPEG. Use the PNG format instead: map1.compress(Bitmap.CompressFormat.PNG, 100, baos); and String imgTag = “<img src=”data:image/png;base64,” + imgToString + “” align=’left’ bgcolor=”ff0000″/>”;