为了账号安全,请及时绑定邮箱和手机立即绑定

LinearLayout设置background不显示所设置的图片

LinearLayout设置background不显示所设置的图片

繁华开满天机 2019-03-01 10:59:56
xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/background_login" > <FrameLayout android:id="@+id/fragment_login_replace" android:layout_width="match_parent" android:layout_height="match_parent"/> </LinearLayout> xml=====>fragment_login_replace <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="@drawable/background_login" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:weightSum="1"> <RelativeLayout android:layout_width="match_parent" android:layout_height="100dp" android:orientation="vertical" android:layout_weight="0.29"> <ImageView android:id="@+id/imageView" android:layout_width="50dp" android:layout_height="50dp" android:src="@drawable/logo_red" android:layout_centerVertical="true" android:layout_alignLeft="@+id/textView" android:layout_alignStart="@+id/textView" /> <TextView android:id="@+id/textView" android:layout_width="219dp" android:layout_height="wrap_content" android:textSize="30dp" android:text="Home Work" android:textAllCaps="false" android:textColor="#ffff" android:textStyle="bold" android:layout_marginLeft="31dp" android:layout_marginStart="31dp" android:layout_below="@+id/imageView" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" /> </RelativeLayout> <android.support.design.widget.TextInputLayout android:layout_marginLeft="25dp" android:layout_marginRight="20dp" android:layout_marginTop="35dp" android:id="@+id/textinput_login_username" android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:id="@+id/edit_login_username" android:layout_width="match_parent" android:layout_height="match_parent" android:hint="用户名" /> </android.support.design.widget.TextInputLayout> <android.support.design.widget.TextInputLayout android:layout_marginLeft="25dp" android:layout_marginRight="20dp" android:id="@+id/textinput_login_password" android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:id="@+id/edit_login_password" android:layout_width="match_parent" android:layout_height="match_parent" android:hint="密码" /> </android.support.design.widget.TextInputLayout> <Button android:id="@+id/button_login" android:layout_width="287dp" android:layout_height="wrap_content" android:layout_marginLeft="43dp" android:layout_marginRight="20dp" android:layout_marginTop="40dp" android:background="@color/colorPrimary" android:text="登录" android:textColor="@color/white" /> <TextView android:id="@+id/text_register" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/button_login" android:layout_marginTop="10dp" android:layout_weight="0.03" android:gravity="center_horizontal" android:text="没有账号?注册一个" android:textColor="@color/colorPrimary" android:textSize="15sp" /> </LinearLayout> Activity public void init(LoginFragment fragment){ FragmentTransaction transaction = activity.getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.fragment_login_replace, fragment, "login"); transaction.commit(); } 背景显示为白色 很是纠结
查看完整描述

3 回答

?
吃鸡游戏

TA贡献1829条经验 获得超7个赞

我是有 三个文件夹 一个drawable drawable-v21 drawable-xxhdpi
之前放在了drawable内 背景图片被 94kb的jpg 格式
然后 放在drawable-xxhdpi 下 就可以成功显示了

有没有知道原因的

查看完整回答
反对 回复 2019-03-01
?
一只名叫tom的猫

TA贡献1906条经验 获得超3个赞

fragment使用肯定会用自己的根布局的图片,你把背景写到fragment_login_replace.xml这个文件不就好了

查看完整回答
反对 回复 2019-03-01
  • 3 回答
  • 0 关注
  • 1134 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信