布局背景颜色在运行时消失 [英] Layout background color disappears on runtime
问题描述
我正在尝试为视频播放器创建一个修剪器栏,在设计时一切正常,但是在运行时,我的栏的背景颜色消失了
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
trimmer_bar:
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:
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>
我不能在此处粘贴trimmerbar.java的整个代码,因为它太长了,因为它使视频进度在小节和播放器之间保持同步...但是我搜索了所有内容,我的课程中都没有提到setBackground或相关的唯一可处理的布局字段是页边距
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
推荐答案
您设置tools:background="#ab5442"
(仅用于预览),用于在运行时设置android:background="#ab5442"
中设置背景
工具命名空间只是为了在开发时提供便利,并且不影响运行时
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
这篇关于布局背景颜色在运行时消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!