美文网首页
萌新在Android开发遇到的错误解决方法

萌新在Android开发遇到的错误解决方法

作者: 都不想悔疚 | 来源:发表于2018-01-27 12:12 被阅读0次

1. eventbus在使用中注意生命周期的问题,intent传递数据时未启动activity传递数据到达不了。

2.之前依赖仿B站搜索框出现问题 ,仿B站搜索框的github是:https://github.com/wenwenwen888/SearchDialog 修改了以下代码即可。

    compile 'com.android.support:support-v4:27.0.2'
    compile 'com.android.support:appcompat-v7:27.0.2'
    compile 'com.android.support:recyclerview-v7:27.0.2'
    compile 'com.android.support:design:27.0.2'

3.textView点击事件需要设置

  android:clickable="true"

4. 在引用PictureSelector2.0中出现和项目中的glide4.5发生冲突,错误代码如下

java.lang.NoSuchMethodError: com.bumptech.glide.RequestBuilder.into
at com.luck.picture.lib.adapter.PictureImageGridAdapter.onBindViewHolder.....

将项目中依赖的glide取消依赖后使用PictureSelector中的glide即可。

5.页面中底部的评论分享栏是要放在RelativeLayout下才能够显示在页面上面。

6.当TabLayout 在宽屏幕的设备上,如平板横屏的时候,tab的宽度超过一定值后,就不在平均分配宽度,而是居中显示。此时设置app:tabMode="fixed"或者top_table.setTabMode(TabLayout.MODE_FIXED);不在起作用。效果如图:

此时的解决办法,设置app:tabMaxWidth="0dp" 此值即可解决
<android.support.design.widget.TabLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabMaxWidth="0dp"
            app:tabGravity="fill"
            app:tabMode="fixed" />

7. RecyclerView 视图中 item的设置不正确会导致宽高显示不正常。以下为解决后的item设置:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:gravity="center"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/iv_item_portrait"
        android:layout_width="28dp"
        android:layout_height="28dp"
        android:layout_gravity="center_horizontal"
        android:layout_marginRight="@dimen/activity_space_little" />
</LinearLayout>

相关文章

网友评论

      本文标题:萌新在Android开发遇到的错误解决方法

      本文链接:https://www.haomeiwen.com/subject/zddnaxtx.html