2018-04-12工作日志,同一布局不同机型效果有差异

适配问题,相同布局不同手机展示差异- android:layout_width="wrap_content"

xml布局:

<LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="@dimen/dp_40"
                        android:layout_marginLeft="@dimen/dp_36"
                        android:layout_marginTop="@dimen/dp_40"
                        android:text="账   户    名"
                        android:textColor="@color/color_333333"
                        android:textSize="@dimen/sp_42" />

                    <EditText
                        android:id="@+id/et_username"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_marginLeft="42dp"
                        android:background="@color/color_00000000"
                        android:gravity="center|left"
                        android:hint="请输入真实姓名"
                        android:textColor="@color/color_333333"
                        android:textSize="@dimen/sp_36" />
                </LinearLayout>

S80502-175216.jpg

 

Screenshot_20180502-175924.png

截屏_20180502_175253.jpg

查看项目打印日志,出现如下异常,归根到底是没有关闭流。okhttp3框架中的Response对象使用后要及时的关闭 response.close()。

A resource was acquired at attached stack trace but never released.
See java.io.Closeable for information on avoiding resource leaks.
java.lang.Throwable: Explicit termination method 'response.body().close()' not called
at dalvik.system.CloseGuard.open(CloseGuard.java:180)
at java.lang.reflect.Method.invoke(Native Method)
at okhttp3.internal.platform.AndroidPlatform$CloseGuard.createAndOpen(AndroidPlatform.java:272)
at okhttp3.internal.platform.AndroidPlatform.getStackTraceForCloseable(AndroidPlatform.java:138)
at okhttp3.RealCall.captureCallStackTrace(RealCall.java:78)
at okhttp3.RealCall.enqueue(RealCall.java:87)
at com.lzy.okgo.cache.policy.BaseCachePolicy.requestNetworkAsync(BaseCachePolicy.java:129)
at com.lzy.okgo.cache.policy.NoCachePolicy$3.run(NoCachePolicy.java:85)
at android.os.Handler.handleCallback(Handler.java:761)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)

添加碎片的方式一

        FragmentManager manager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = manager.beginTransaction();
        FragmentDiaryReward diaryReward = (FragmentDiaryReward) Fragment.instantiate(this, FragmentDiaryReward.class.getName(), null);
        fragmentTransaction.add(R.id.frame_content, diaryReward, diaryReward.getClass().getName());
        fragmentTransaction.commit();

视频背景图宽高比计算方法

  Glide.with(mContext).load(bean.getShare_cover()).placeholder(R.mipmap.zhanwei3).
                listener(new RequestListener<String, GlideDrawable>() {
                    @Override
                    public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
                        return false;
                    }

                    @Override
                    public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                        if (iv_share_video2 == null) {
                            return false;
                        }
                        if (iv_share_video2.getScaleType() != ImageView.ScaleType.FIT_XY) {
                            iv_share_video2.setScaleType(ImageView.ScaleType.FIT_XY);
                        }
                        ViewGroup.LayoutParams params = iv_share_video2.getLayoutParams();
                        int vw = iv_share_video2.getWidth() - iv_share_video2.getPaddingLeft() - iv_share_video2.getPaddingRight();
                        float scale = (float) vw / (float) resource.getIntrinsicWidth();
                        int vh = Math.round(resource.getIntrinsicHeight() * scale);
                        params.height = vh + iv_share_video2.getPaddingTop() + iv_share_video2.getPaddingBottom();
                        iv_share_video2.setLayoutParams(params);
                        return false;
                    }
                }).into(iv_share_video2);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值