Share Coding

Tutorials, Problems, Stuffs …

Category Archives: BahBahBah

Mapping data between 2 excel sheets

There are 2 excel sheets, left one is the full list of records and the right one is the filtered list I need to retrieve the ID from sheet 1 by given Ref No.

a.png

formula:

=INDEX(‘Full list‘!$A1:$A13507,MATCH(A3,’Full list‘!$B1:$B13507,0),0)

Result:

b.png

 

Advertisements

Android status bar background color

To change status bar background color, setup the following in your v21/style.xml, inside your style.
Yes, they are only working after API 21.

<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:fitsSystemWindows">true</item>
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:statusBarColor">@color/bgStatusBar</item>

 

For API level > 19
In older version, API level 19, cannot change background color on status bar.
But you can setup a ImageView behide it, and make the status bar full transprant.
Write down the following in your v19/style.xml, inside your style.

<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">false</item>

In your Activity, add those code at onCreate()

// Lower then API level 19, do nothing
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
    return;
}
// Change the background image / color of the st
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);

    if (contentView.getChildCount() > 1) {
        contentView.removeViewAt(1);
    }

    int res = resources.getIdentifier("status_bar_height", "dimen", "android");
    int height = 0;
    if (res != 0)
        height = resources.getDimensionPixelSize(res);

    ImageView image = new ImageView(activity);
    image.setLayoutParams(
            new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height)
    );
    image.setImageResource(imageRes);
    image.setScaleType(ImageView.ScaleType.FIT_XY);

    contentView.addView(image);
}

 
Moreover, it is suggested to keep the fitsSystemWindows at style or the root layout.
To use adjustResize function to solve keyboard overlap edittext problem, it must be kept.

<item name="android:fitsSystemWindows">true</item>

Android keyboard overlap with the content

Write this on your activity, done.

android:windowSoftInputMode = "adjustResize"

If not working, your root element at xml must contain the following attribute.

android:fitSysytemWindow="true"

Div has equal width and space

Example: three or two span share the equal space in a row. (inline-block)

space

Read more of this post

Drawable localization

test

 

Open a folder with name ‘drawable-en’ when the local setting is ‘en’.
My default language is ‘zh’, so the image with chines word store at ‘drawable’ folder.
At the same time, we should have ‘values’ and ‘values-en’ folders.

Read more of this post