Home > Mobile >  Android studio using background can't change the background picture
Android studio using background can't change the background picture

Time:11-06

Has just started to learn android studio found using background there is no way to change the button color or background, use backgrountint can change color but there is no way to need background and shape, the following specific code
 & lt; ? The XML version="1.0" encoding="utf-8"?> 
Android: layout_width="match_parent"
Android: layout_height="match_parent"
Android: padding="15 dp" & gt;
Android: layout_width="match_parent"
Android: layout_height="wrap_content"
The android: id="@ + id/btn_2"
Android: text="button" 1
Android: textSize="20 sp"
Android: textColor="# 4 fd2d6"
Android: background="@ drawable/bg_btn1"
Android: layout_below="@ id/btn_1"
Android: layout_marginTop="10 dp"
/>

What is the blue background

CodePudding user response:

Blue?? Isn't this purple? Only from the point of view of layout file no problem, should not change the background

CodePudding user response:

Don't quite understand what you said is how to change, the code to dynamically change or XML inside change?
XML to stick down your bg_btn1

At the same time, set the color with shape
Bg_btn1. XML below

<? The XML version="1.0" encoding="utf-8"?>

Android: width="2 dp"
Android: color="# FFFFFF"/& gt;


Don't know under the baidu label attribute

CodePudding user response:

This code is bg_btn1
 
<? The XML version="1.0" encoding="utf-8"?>
Android: shape="rectangle" & gt;

Android: width="1 dp"
Android: color="# 000000"/& gt;

Android: the radius="5 dp/& gt;"

Another problem is the direct write android: background="# 000000" there is no way to change the background color

CodePudding user response:


Android: width="1 dp"
Android: color="# 000000"/& gt;

Stroke stroke stroke stroke stroke
Solid solid solid solid solid
  • Related