The following is the pit I stepped on, hope to see this will allow you to step on my head over it 🙂
-
In XML, you’re going to use a View, not a View
-
Stop resource, pop, keyboard in onPause(), not onStop()
-
Js calls Android methods. The parameter of this method should be String. Otherwise, there are multiple JS methods calling Android methods in H5 page, and the parameter is int = 0.
@javascriptInterface public void lookUserDetailedInfor(String ID) {// In the corresponding JS douQuJS.lookUserDetailedInfor(data); The H5 page contains multiple js methods that call Android methods, and the parameter is int = 0. NSLog.w(TAG,"WebViewFragment{} ... lookUserDetailedInfor() --> id = " + id);
}
Copy the code
-
SetClickable (True) does not work: setClickable(false) must be placed after setOnClickListener, otherwise it will not work
-
When a view is not displayed, consider whether ButterKnife creates a field XXView along with new XXView();
-
Git pull generates an error message when updating a local code:
error: Your local changes to the following files would be overwritten by merge:
app/src/main/java/com/blankj/androidutilcode/activity/KeyboardActivity.java
Please commit your changes or stash them before you merge.
Aborting
Copy the code
Solutions:
git checkout -f
git pull
Copy the code
- Sometimes scrollTo() doesn’t work when you don’t play the keyboard. Try this:
HandlerUtil.runOnUiThread(new Runnable() {
@Override
public void run() { KeyboardUtil.showSoftInput(et_new_label); }}, 100);Copy the code
- Check the dependencies of the project.
./gradlew -q dependencies <module-name>:dependencies --configuration compile
Copy the code
- ScrollView listens setOnScrollChangeListener Y changes the position of the titleBar of transparency, sometimes will affect the impression of other pages, very strange. Try this:
rl_family_title_bar.setBackgroundColor(Color.WHITE); Rl_family_title_bar.getbackground ().setalpha (0); rl_familY_titLE_bar.getBackground (). nsv_root.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
int alpha = 255 * scrollY / LocalDisplay.dp2px(257);
if (alpha < 0) {
alpha = 0;
} else if (alpha > 255) {
alpha = 255;
}
rl_family_title_bar.getBackground().setAlpha(alpha);
if(alpha < 128) {
tv_title.setTextColor(Color.WHITE);
iv_back.setImageResource(R.drawable.btn_menu_back_white);
} else{ tv_title.setTextColor(Color.BLACK); iv_back.setImageResource(R.drawable.btn_menu_back); }}});Copy the code
- The SurfaceView flash screen is faulty
getWindow().setFormat(PixelFormat.TRANSLUCENT); // in case: Android SurfaceView flash screen problemCopy the code