I have worked on a small app where I designed multiple pages. however the first page is not displaying the correct background color when I run the app , although I'm 100% sure the color is amended. below you see the codes of xml. also even the action bar is still there although I removed and used no action bar them.
what seems to be the issue ? note: Android studio updated
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:background="#243447"
tools:context="#243447">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="97dp"
android:fontFamily="sans-serif-smallcaps"
android:text="Choose your focus"
android:textColor="@android:color/holo_red_light"
android:textSize="24sp" />
<RelativeLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="413dp"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginStart="0dp"
android:layout_marginBottom="0dp"
tools:background="#243447">
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/button2"
android:layout_alignTop="@+id/button5"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="32dp"
android:layout_marginRight="32dp"
android:layout_marginBottom="195dp"
android:background="#243447"
android:fontFamily="sans-serif-smallcaps"
android:hapticFeedbackEnabled="false"
android:shadowColor="@android:color/background_dark"
android:text="Work"
android:textAllCaps="false"
android:textColor="@android:color/holo_red_light"
android:textColorHighlight="@android:color/darker_gray"
android:textSize="14sp" />
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button4"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="32dp"
android:layout_marginLeft="32dp"
android:layout_marginTop="61dp"
android:layout_marginBottom="195dp"
android:background="#243447"
android:fontFamily="sans-serif-smallcaps"
android:hapticFeedbackEnabled="false"
android:shadowColor="@android:color/background_dark"
android:text="Community"
android:textAllCaps="false"
android:textColor="@android:color/holo_red_light"
android:textColorHighlight="@android:color/darker_gray"
android:textSize="14sp" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/button2"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_marginStart="32dp"
android:layout_marginLeft="32dp"
android:layout_marginTop="0dp"
android:background="#243447"
android:fontFamily="sans-serif-smallcaps"
android:hapticFeedbackEnabled="false"
android:shadowColor="@android:color/background_dark"
android:text="Relgion"
android:textAllCaps="false"
android:textColor="@android:color/holo_red_light"
android:textColorHighlight="@android:color/darker_gray"
android:textSize="14sp" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginTop="61dp"
android:layout_marginEnd="32dp"
android:layout_marginRight="32dp"
android:background="#243447"
android:fontFamily="sans-serif-smallcaps"
android:hapticFeedbackEnabled="false"
android:shadowColor="@android:color/background_light"
android:text="Health"
android:textAllCaps="false"
android:textColor="@android:color/holo_red_light"
android:textColorHighlight="@android:color/darker_gray"
android:textSize="14sp" />
</RelativeLayout>
</RelativeLayout>
You are using tools:background="#243447"
the keyword tools is only for the screen preview in android studio.
If you would like to have the background color in your app you need to use the keyword android android:background="#243447"
Try to use
android:background="#243447"
instead of
tools:background="#243447"
and you have to put your class name in
tools:context=".ActivityName"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.