Layout background color disappears on runtime
Asked Answered
W

1

0

I'm trying to create a trimmer bar to my video player, on design time it's everything ok but on runtime the background color of my bar disappears

enter image description here

trimmer_bar:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <RelativeLayout
        android:id="@+id/thumbsBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="visible"
        tools:background="#ab5442">


        <ImageView
            android:id="@+id/leftThumb"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription=""
            android:scaleType="fitStart"
            android:src="@drawable/ic_left_thumb" />


        <ImageView
            android:id="@+id/rightThumb"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:contentDescription=""
            android:scaleType="fitEnd"
            android:src="@drawable/ic_right_thumb" />


    </RelativeLayout>

    <ImageView
        android:id="@+id/progressIndicator"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerVertical="true"
        android:layout_marginStart="60dp"

        android:contentDescription=""
        android:src="@android:drawable/btn_star_big_on" />

</RelativeLayout>

main_activity:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="match_parent"
    android:layout_height="match_parent"
    tools:context=".activities.Main2Activity"
    android:orientation="vertical">


    <com.tomatedigital.instagram.longstories.ui.TrimmerBar
        android:layout_width="match_parent"
        android:layout_height="wrap_content">


    </com.tomatedigital.instagram.longstories.ui.TrimmerBar>

</LinearLayout>

i cannot paste the whole code of trimmerbar.java here because it's too long as it keeps the video progress synchronized between the bar and the player... but i've searched EVERYWHERE, none of my class has any mention to setBackground or related the only layout field i handle are the margins

Whippersnapper answered 15/5, 2018 at 20:5 Comment(0)
A
3

You set tools:background="#ab5442"(It setting just for preview), for setting backgroun in runtime set android:background="#ab5442" tools namespace just for convinience when developing and not affecting runtime

Apatetic answered 15/5, 2018 at 20:10 Comment(1)
also I would recommend not to use RelativeLayout inside RelativeLayout, for better performance you can use one ConstraintLayout see: developer.android.com/training/constraint-layoutOgg

© 2022 - 2024 — McMap. All rights reserved.